What is the most efficient and robust way to program ASP.NET with javascript? -


I wanted to know what is the best way to program ASP.NET with JS? So far, I am trying to code with codebehind features. Add ("onclick," ....); Is there a better and better way to use JS with ASP.NET?

Thank you

Writing all your functions in a different JS file is more flexible Now what are you doing The problem may be the control ID in your JS file. Okay, there are many ways.

Hardcoding

Just look at the Source View and Identify Control which you want to use. It's easy, but if you want to change the control ID some time then the related function will not work

something like that

all in the ASPX file Announce a variable with client id that uses in JS file

  var MyControlIDs = {"Textbox1": "& lt;% = Textbox1.ClientID%>", " Label1 ":" & lt;% = Label1.ClentID%> "};   

and in your JS file var mycontrol = window .MyControlIDs and anywhere you want

var textbox = document .getElementById (mycontrol.TextBox1);

Comments

Popular posts from this blog

qt - switch/case statement in C++ with a QString type -

python - sqlite3.OperationalError: near "REFERENCES": syntax error - foreign key creating -

Python's equivalent for Ruby's define_method? -