.aspx.cs+javascript [modified]
-
Hi All,how can I pass variables from .aspx.cs to javascript...in javascript file how can I receive them? please help me.. -- modified at 6:40 Friday 29th June, 2007
Hi,Im Razana
-
Hi All,how can I pass variables from .aspx.cs to javascript...in javascript file how can I receive them? please help me.. -- modified at 6:40 Friday 29th June, 2007
Hi,Im Razana
I feel like I've answered this one three times today..... Just use the RegisterClientScriptBlock method on the page class to write javascript into the page, and build a string in your code behind that creates the variable.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Hi All,how can I pass variables from .aspx.cs to javascript...in javascript file how can I receive them? please help me.. -- modified at 6:40 Friday 29th June, 2007
Hi,Im Razana
Yes you can use RegisterClientScriptBlock... but if you put some dynamic values in javascript you can use this one also..very easy and stright forward. string str="Some Dynamic String"; Response.Write(" var ServerStr="+str+" "); cheers :):-D
Ravi Kant Srivastava (System Analyst) HandsOn Technology & Engineering Gurgaon (India) e-mail:ravikant@hte.co.in
Cell: +91-9999611388
-
Yes you can use RegisterClientScriptBlock... but if you put some dynamic values in javascript you can use this one also..very easy and stright forward. string str="Some Dynamic String"; Response.Write(" var ServerStr="+str+" "); cheers :):-D
Ravi Kant Srivastava (System Analyst) HandsOn Technology & Engineering Gurgaon (India) e-mail:ravikant@hte.co.in
Cell: +91-9999611388
Some problems with this 1 - you didn't put the variable in quotes 2 - Response.Write always puts the text at the top of the page, above the head tag, this is bad. 3 - RegisterClientScriptBlock lets you stop a script from being inserted more than once. Ideally, if you want full control of the text's location, you should put it in the aspx, or put a literal control in the aspx that you can set to contain the script.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Some problems with this 1 - you didn't put the variable in quotes 2 - Response.Write always puts the text at the top of the page, above the head tag, this is bad. 3 - RegisterClientScriptBlock lets you stop a script from being inserted more than once. Ideally, if you want full control of the text's location, you should put it in the aspx, or put a literal control in the aspx that you can set to contain the script.
Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
I need to do 3 Steps.. 1.In java Script file, I've to get the value of textbox which is placed on .aspx file.. 2.I've pass this value to another .aspx file to check whether the value of text box exsist in database.. 3.Finally I have to pass a variable from the second .aspx file to the first .aspx file... I did the above to... I dont know the third one...that is my problem... txtajaxscript.js ================= var http = getHTTPObject(); var url="txtajaxcheck.aspx?id="; function handleHttpResponse() { if (http.readyState == 4) { results = http.responseText; document.getElementById("lbltxt").innerHTML= results; } } function txtdisplay() { var txtvalue=document.getElementById("Text1").value; document.getElementById("lbltxt").innerHTML=txtvalue ; var http = getHTTPObject(); http.open("GET", url + escape(txtvalue), true); http.onreadystatechange = handleHttpResponse; http.send(null); var role = "<%=role%>"; document.getElementById("lbltxt").innerHTML=role ; } function getHTTPObject() { if (typeof XMLHttpRequest != 'undefined') { return new XMLHttpRequest(); } try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } return false; } now I have to pass a variable from txtajaxcheck.aspx to txtajaxscript.js...and I have to get a variable here which is sent by txtajaxcheck.aspx ... Help me please....
Hi,Im Razana