Sunday, April 08, 2007

Asp Tips & Tricks

----------------------------------------------------------
Using DataFormatString To Customize Data
----------------------------------------------------------

When trying to Customize Date Time by Removing Hours, ..
Use DataFormatString:


DataField="DateEnd" DataFormatString="{0:dd/MM/yyyy}" HtmlEncode="false"

Note :- Disable HtmlEncode for this Column in order to work :-)

----------------------------------------------------------
Creating Master Details View
----------------------------------------------------------
Use DataList To Create Master Details View By including DataGrid in its ItemTemplate to bind it to itemid for details.

Note :- Use Databind Event to Bind Grid With Details Accordiong To Selected ID
----------------------------------------------------------
Enum Stuff
----------------------------------------------------------
Get Value Of Item in Enum using (int)Enum
----------------------------------------------------------
Calling JS Function Using Server Side Control
----------------------------------------------------------
How To call Js function when dealing with Server side
controls

protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
btnJSTest.Attributes.Add("onclick", "return TestJS();");
}
}

JS Fn
------
function TestJS()
{
if(1==1)
{
alert("True");
return true;
}
else
{
alert("False");
return false;
}
}

0 comments: