Saturday, September 4, 2010

Some Important Operation



Get Item Control Value from server Side
Convert.ToString((DataGrdi.Items[e.Item.ItemIndex].FindControl("hdnfield") as HiddenField).Value);

Get Data Kety Values
Convert.ToString(DataGrid.DataKeys[e.Item.ItemIndex].ToString());

Using Of string.IsNullOrEmpty

Java Script Message From Server Side





Sample code -

string script = string.Format("alert('{0}');", cleanMessage);
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert")) 
{
    page.ClientScript.RegisterClientScriptBlock(page.GetType(), "alert", script, true /* addScriptTags */);
}

Call parent function by User control ( by Reflection Class ) Asp.Net V Imp




Here is a simple command to invoke parent function from the User control

this.Page.GetType().InvokeMember("DisplayMessage", System.Reflection.BindingFlags.InvokeMethod, null, this.Page, new object[] { txtMessage.Text });


We need this most of the time when applying the facets at the page level. and the child components need to update the parent one,  As an example below.