acessing a user control's fields from a web page
-
hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?
From code behind try this.textboxname.Value (C#) Using javascript document.getElementById("textboxname").value Subhasis Chandra
-
hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?
Hi, You can use as much levels of usercontrols as you like. You can simply get the value through javascript. "you have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox." place all these as these are written Then run the project. In the explorer, check the source of the page(view source : right click on internet explorer page and view source). Copy the ID for the textbox generated by the ASP.NET This ID never changes. Then add this function in the main web form WF_A (aspx): function getTextBoxValue() { alert(document.getElementById(UC_A:UC_B:TextBox1').value); } Call this function where you want to get the text, like OnClick of a Button : Button1.Attributes.Add("OnClick","javascript:getTextBoxValue()"); I feel this will help you. Thanks Sushant Duggal.
-
hi, I have a web form named WF_A. on this web page i have a user control named UC_A and in user control UC_A there is another user control named UC_B. in user control UC_B there is a Textbox. How can i get values from is text box from WF_A?
I missed a quote here : alert(document.getElementById('UC_A:UC_B:TextBox1').value); Sushant Duggal.
-
I missed a quote here : alert(document.getElementById('UC_A:UC_B:TextBox1').value); Sushant Duggal.