Posts

Showing posts from March, 2008

Cross Page PostBack Using ListBox

Scenario:- You have a list box on a web page. You select value in the Listbox & Control is transferred to another page which shows value selected in the ListBox. Solution:- As there is no button on the page, ListBox AutoPostback should be true. But ListBox PostBacks to same Page. Here requirement is that it should post to other page. So we need to change the property of ListBox. We can not access Controls of Previous Page from Next Page. So we will define a Public property on First Page & access that on Second Page. Code Snippet:- Code on FirstPage.aspx.cs:- public partial class ListBoxCrossPagePostBack : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { PostBackOptions options = new PostBackOptions(ListBox1); options.ActionUrl = "SecondPage.aspx"; string s = Page.ClientScript.GetPostBackEventReference(options); ListBox1.Attributes["onchange"] = s; } public Lis
CommandEventArgs contain CommandName & CommandArgument Properties Button by default behaves as Submit button, but if we provide CommandName then itbehaves as CommandButton CommandButton raises CommandEvent . It will be useful when u want to pass event related info to event handler Features Of webServer Contorls:- Intrinsic Events Eg. Button has intrinsic events of click and command But Datagrid has 9 intrinsic events Event ArgumentsAll Events in .Net framework passes 2 arguments. 1.Object that raised event 2.Object that contains event specific info. If Event doesn't have event specific info then it passes System.EventArgs by default. Otherwise it passes EventSpecific data such as ImageClickEventArgs which is derived from System.EventArgs AutoPostback It causes Immidiate Postback as a result of click event of Button Control BubbledEvents All the events raised at child level are bubbled up to p
How To Hide And Show ListBox in JavaScript:- To Hide document.getElementById(ListBoxId).style.visibility="hidden" To Show document.getElementById(ListBoxId).style.visibility="visible"
How to Access Selected Value Of a DropDownList In JavaScript:- ddl.options[ddl.selectedIndex].value ; This is the way that I have found to access a DropDownList. Thogh there is SelectedValue property of a dropdownList, It did not work.