简体   繁体   中英

How to write javascript on asp.net page

如何在asp.net页面上编写javascript代码(例如(输入框))以更好的方式获取价值....或其他控件消息框(警告,确认,......(如果可以,请我一个例子吗?)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM