How to write javascript code on asp.net page such as (input box) to get value in a better manner .... or another controls message boxes (alert,confirm,...... (please if you c开发者_如何学Can, give me an example? )
as you would on a "normal" html page :)
you can enhance your scripts - no, sometimes you MUST - with eg.
<%= this.inputBox.ClientID %>
i would recommend jQuery for such enhancements ... its feature rich, easy to learn, ...
you could do eg.
var $inputBox = $('#<%= this.inputBox.ClientID %>');
$inputBox.hide();
var oldValue = $inputBox.val();
$inputBox.val('now it has no value');
.. and many more!
there are many tutorials on the net... to give a very rough overview, try this
You can use the ClientID
property. Example
<img src="images\cal.gif"
onclick="openCalendar(<% = txtDate.ClientID %>, 150, -150);return false;" />
Soure
精彩评论