0

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 can, give me an example? )

4
  • the best option is to put all the javascript functions in a separate .js file and while deloying the application minify the .js and use it. Commented Mar 21, 2011 at 9:50
  • @Aravind: minifying is sometimes just too overrated... at least you've got the browser cache :) if you'd really like to optimize, you'd better create one big file to minimize the requests! Commented Mar 21, 2011 at 15:14
  • @Andreas one cannot generalise it and have to deal with it on a case to case basis. Commented Mar 22, 2011 at 6:54
  • @Aravind: neither you can... so throwing "MINIMIZE!" in is as stupid as my suggestion :) Commented Mar 22, 2011 at 8:47

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

0

You can use the ClientID property. Example

<img src="images\cal.gif" 
onclick="openCalendar(<% = txtDate.ClientID %>, 150, -150);return false;" />

Soure

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.