window.location.Reload() is refresh page, it will submit the data again and has a alert message is continue.
2012年12月28日 星期五
window.location.Reload() and window.location.href=window.location.href; difference
2012年11月21日 星期三
Get screen width Javascript
<script type="text/javascript"
language="javascript">
if
(document.getElementById("rightMenu")
!= null) {
if
(screen.width < 1200) {
document.getElementById("rightMenu").style.display = "none";
}
}
</script>
position fixed for IE6
Add this code in the header
<!--[if IE 6]>
<style type="text/css">
.promomenu{
position:absolute; /* position fixed for IE6 */
top:expression(200+((e=document.documentElement.scrollTop)?e:document.body.scrollTop)+'px');
right:expression(0+((e=document.documentElement.scrollLeft)?e:document.body.scrollLeft)+'px');
}
</style>
<![endif]-->
2012年9月20日 星期四
日期時間倒數器
<SCRIPT type="text/javascript" language="javascript">
var
startDate = new Date();
var
endDate = new Date(2012, 8, 20, 10, 00);
var
spantime = (endDate - startDate) / 1000;
function
getString(dt) {
return
dt.getFullYear() + "?" +
(dt.getMonth() + 1) + "?" +
dt.getDate() + "?" + dt.getHours()
+ "?" + dt.getMinutes() + "?";
}
function
leftPad(n, len) {
return
(new Array(len - String(n).length + 1)).join("0").concat(n);
}
function
cal() {
spantime--;
var d
= Math.floor(spantime / (24 * 3600));
var h
= Math.floor((spantime % (24 * 3600)) / 3600);
var m
= Math.floor((spantime % 3600) / (60));
var s
= Math.floor(spantime % 60);
str = d + "?
" + h + "?" + m + "? " + s + "?
";
document.getElementById("hours2").innerHTML = leftPad(h, 2);
document.getElementById("min2").innerHTML = leftPad(m, 2);
document.getElementById("sec2").innerHTML = leftPad(s, 2);
if
(document.getElementById("hours3")
!= null) {
document.getElementById("hours3").innerHTML = leftPad(h, 2);
document.getElementById("min3").innerHTML = leftPad(m, 2);
document.getElementById("sec3").innerHTML = leftPad(s, 2);
}
}
window.onload = function
() {
setInterval(cal, 1000);
}
</SCRIPT>
2012年4月18日 星期三
DetailsView FindControl when Edit or Insert mode
Must in the PreRender or ItemCreated even.
.aspx file:
.cs file:
.aspx file:
onprerender="DetailsView1_PreRender"
.cs file:
protected void
DetailsView1_PreRender(object sender, EventArgs e)
{
if
(IsPostBack)
{
DetailsView
detailsView = (DetailsView)sender;
if
(detailsView.CurrentMode == DetailsViewMode.Edit)
{
DropDownList
dropDownList = (DropDownList)detailsView.FindControl("DropDownList1");
dropDownList.Items.Add(new ListItem("text", "value"));
}
}
}
2012年2月21日 星期二
Create Google Calendar Event using Google Calendar API
Google api asp.net client download
public void
CreateCalendarEvent(string content)
{
CalendarService
calendarService = new CalendarService("CNBlogsMeeting");
calendarService.setUserCredentials("Email", "Password");
EventEntry
entry = new EventEntry();
//日曆標題與內容
entry.Title.Text = content;
entry.Content.Content = content;
//開始與結束時間,17:00~18:00
When
eventTime = new When(DateTime.Now,
DateTime.Now);
entry.Times.Add(eventTime);
//需要邀請的参會者
//Who who
= new Who();
//who.Email
= "cho88hk@gmail.com";
//who.Rel
= "http://www.yahoo.com.hk";
//entry.Participants.Add(who);
//给被邀請者發送通知
//entry.Notifications
= true;
//被邀請者可以修改該日曆項
//entry.ExtensionElements.Add(new
GuestsCanModify("true"));
Uri
postUri = new Uri("https://www.google.com/calendar/feeds/default/private/full");
AtomEntry
insertEntry = calendarService.Insert(postUri, entry);
//Assert.NotNull(insertEntry);
}
2012年2月9日 星期四
Formatting the GridView Based on the Underlying Data
protected void
GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType == DataControlRowType.DataRow)
{
//
determine the value of the status field
int
status = Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "status"));
// color
the background of the row
switch
(status)
{
case
0:
e.Row.BackColor = Color.LightGreen;
break;
case
1:
e.Row.BackColor = Color.Red;
break;
case
2:
e.Row.BackColor = Color.Blue ;
break;
}
}
}
訂閱:
文章 (Atom)