Reference of WEb Control in the Html Page
-
Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................
-
Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................
The individual control id will be a concatenation of the custom control id and the id of the contol within the custom control. I think there is an underscore between the two but I don't recall. If you view the source of your page when it is rendered in IE you will see how it is built up.
Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.
-
Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................
-
Hello all,,, i want to validate my web controls on my aspx pages...but i dont want to use FieldValidators as it is fireing on all the web control buttons i have on that web page. i want to validate the controls by writing Javascript....so it validates atmy client side...like after the head tag in the Html page... function clearControls() { webctrl.text = ""; } then call this Function on the web controls button Click..... My problem is that i am not able to get the reference of the web controls on the html page.... like i m not able to write... document.form1.textbox1.text = "" where textbox1 is as WEb control...same thing i can do for the Html Controls... Let me know how to get the reference... Thanks.... ....................
You can modify the literal control's event's like so:
btnSubmit.Attributes.Add( "onclick", "setDefaultText( e, 'Default Text', '" + txtTest.ClientID + "' );" );
View Source:
on your aspx page or in a .js file:
function setDefaultText(e, newText, target) {
var elt = document.getElementById(target);
elt.value = newText;
}That's the gyst of it. You may have to play around with it a little. Attributes.Add gives you a way to control the attributes of a server control when it is generated by the server. Be careful. You can overwrite attributes that the server may need. For instance submit buttons tend to have a doPostBack Event for the onclick attribute. these can be dealt with, but this will get you started. -- Life's a journey, not a destination