Tuesday, November 30, 2004

datetime format

I have always encouter the problem of when coverting datetime object to the correct format of the string, here is the completed reference of that:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp


Wednesday, November 17, 2004

javascript incompatible issue with IE and firefox

I had some incompatible problems in javascript with firefox, apprently the obj.parentElement is not working in firefox, but I had to use obj.parentNode.
However, for the same issue in datagrid, I had to change this.childNodes[1].childNodes[0] to this.cells[1].firstChild, so that I could access to the first control in each row of the datagrid, which is a checkbox


Wednesday, November 10, 2004

indented in ListItems

I can't not add indented listitems to a dropdown menu, even I add many spaces, like this
dropAction.Items.Add(new ListItem(Server.HtmlDecode(" To Recipient"),"2"));
it won't work! because when converted to html, thes space will despear like I add many usefulless spaces when edit html file. I know I need to use to deal with this, but after I add this it will not give me what I want:

OK, here is the real solution:
dropAction.Items.Add(new ListItem(Server.HtmlDecode(" To Recipient"),"2"));


highlight row in datagrid

resource link:
http://www.dotnetjohn.com/articles.aspx?articleid=12

because datagrid is not like repeater, its row element is not accessbile at design time. so I can't not set onmouseover event to the TD or TR at design time. But I could use datagrid's OnItemDataBound event handler to deal with this.

if (e.Item.ItemType == ListItemType.Item e.Item.ItemType == ListItemType.AlternatingItem)
{
DataRowView row = (DataRowView) e.Item.DataItem;
#region Set MouseOver/MouseOut
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#D6DEEC'");
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#ffffff'");
#endregion
......

in this way, I can even have the datagrid highlight same color but change back to different color when mouseout based on this row's ItemType (Item or AlternatingItem).

Monday, November 08, 2004

Using the enter key to submit a form

resource web page from:
http://www.allasp.net/enterkey.aspx

experience and example:

(1). add onkey down in the html part of an aspx page
onkeydown="if ((event.which && event.which == 13) (event.keyCode && event.keyCode == 13)) {document.forms[0].elements['Button'].click();return false;} else return true;" Runat="server" CssClass="FormText">

'Button' is the ID of the button control I want to fire onclick event,

but this won't work if the text box and button are in a usercontrol, cause final clientid will be changed, and user control id will be added in front of each sub control such as textbox and button, so I need to use the second solution,

(2). add onkeydown attribute in the code behide of the aspx page

string keydownAction = "if ((event.which&&event.which == 13)
(event.keyCode&&event.keyCode == 13)){document.forms[0].elements['"
+btnCreateAlias.ClientID+"'].click();return false;} else return true;";
txtAlias.Attributes.Add("onkeydown",keydownAction);

btnCreateAlias is the button I want to fire onclick event on, when key entered in the textbox.
btnCreateAlias.ClientID is clientid defined by the asp.net at run time, so this solution will be working at page level or inside a user control


Thursday, November 04, 2004

resources

This summary is not available. Please click here to view the post.

Wednesday, November 03, 2004

my first blog

finally decide to have a blog of myself, to write down some experience gained during the programming of ASP.NET

I don't think I can keep pace with this god-damn constantly changing world, but I am still young and working in this shiting IT field, what else can I do?