To use javascript in aspx page for functions like window popup etc...
1)In aspx page html view write the necessary javascript:-
function OpenNew(message){ window.open("NewPage.aspx?" + message,"_blank"); }
2)In code behind write function to register page script ex.
protected void RegisterSubmitErrorScript(string Message) { string script = "< script language="'j a v a s c r i p t '">OpenNew('" + Message + "');"; Page.RegisterStartupScript("OpenNew",script);
}
3)Then anywhere in the page when u want to respond for new window to be open based on any condition being true or false call function above passing parameters if any ex.
RegisterSubmitErrorScript("param1=" + param);
Note:By changing javascript function "window.open" with any of other javascript functions,they can be performed.
Wednesday, December 27, 2006
Friday, December 15, 2006
ASP.NET DropDown -Selection
To change the selected index of a dropdown list already populated if Value or text is known
myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.items.findbytext(strCurrentState))
myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.items.findbyvalue(strCurrentState))
myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.items.findbytext(strCurrentState))
myDropDown.SelectedIndex = myDropDown.Items.IndexOf(myDropDown.items.findbyvalue(strCurrentState))
ASP.NET DataGrid ItemDataBound Facts
--To Access a ROW OR RECORD IN DATAGRID
--during item databound event--
->when using a DataReader
DbDataRecord rv=(DbDataRecord)e.Item.DataItem;
To check if column is null or not
--if(!rv.isDBNull(2)) 2->column index
To get value of paticular column
--rv.GetValue(2)
->when using a DataSet
DataRowView rv=(DataRowView)e.Item.DataItem;
To check if column is null or not
-- if (!rv.Row.IsNull(2)) 2->column index
To get value of paticular column
--rv.Row.ItemArray.GetValue(1)
--to find control in datagrid and change/modify its property ex Label
in item databound value
Label lblType=new Label();
check if datarow or datarecord "not null" as shown above
then lblType=(Label)e.Item.FindControl("lblID"); where lblID->id of control
once we have control can easily modify property,
ex lblType.visible=false;
--during item databound event--
->when using a DataReader
DbDataRecord rv=(DbDataRecord)e.Item.DataItem;
To check if column is null or not
--if(!rv.isDBNull(2)) 2->column index
To get value of paticular column
--rv.GetValue(2)
->when using a DataSet
DataRowView rv=(DataRowView)e.Item.DataItem;
To check if column is null or not
-- if (!rv.Row.IsNull(2)) 2->column index
To get value of paticular column
--rv.Row.ItemArray.GetValue(1)
--to find control in datagrid and change/modify its property ex Label
in item databound value
Label lblType=new Label();
check if datarow or datarecord "not null" as shown above
then lblType=(Label)e.Item.FindControl("lblID"); where lblID->id of control
once we have control can easily modify property,
ex lblType.visible=false;
Subscribe to:
Comments (Atom)