Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. .aspx.cs+javascript [modified]

.aspx.cs+javascript [modified]

Scheduled Pinned Locked Moved C#
questionjavascripthelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    razanabanu
    wrote on last edited by
    #1

    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

    C B 2 Replies Last reply
    0
    • R razanabanu

      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

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      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 )

      1 Reply Last reply
      0
      • R razanabanu

        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

        B Offline
        B Offline
        blue_arc
        wrote on last edited by
        #3

        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

        C 1 Reply Last reply
        0
        • B blue_arc

          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

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          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 )

          R 1 Reply Last reply
          0
          • C Christian Graus

            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 )

            R Offline
            R Offline
            razanabanu
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups