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. Web Development
  3. ASP.NET
  4. pass javascript variable to asp.net function

pass javascript variable to asp.net function

Scheduled Pinned Locked Moved ASP.NET
databasecsharpjavascriptasp-netquestion
12 Posts 4 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.
  • A Abdul Rahman Hamidy

    Dear All, I am looking for a way where I want to pass javascript variable to asp.net function bellow is what I am doing right now

    function openWindowWithArg()
    {
    var myParam = window.dialogArguments;
    var param = document.getElementById('TextBox1');
    param.value = myParam.param;
    <%bindAdvancedFilterData("1,2"); %>; //this works fine
    <%bindAdvancedFilterData(param.value); %>; //this doesnt work, I want to do it this way
    }

    any ideas how i can pass param.value to the asp.net method bindAdvancedFilterData()?, I can do this using query string and session but May be it should be possible to do it like this?

    Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

    S Offline
    S Offline
    sashidhar
    wrote on last edited by
    #2

    Why dont u use hidden field..? are u trying to call a method? what is bindAdvancedFilterData()? in here..!

    LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

    A N 2 Replies Last reply
    0
    • S sashidhar

      Why dont u use hidden field..? are u trying to call a method? what is bindAdvancedFilterData()? in here..!

      LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

      A Offline
      A Offline
      Abdul Rahman Hamidy
      wrote on last edited by
      #3

      well, I am calling openWindowWithArg function in onload of body as bellow

      <body onload="openWindowWithArg();">

      and the function

      <%bindAdvancedFilterData("1,2"); %>;

      is asp.net function which I am calling it from javascript. How to pass javascript variables to asp.net method? which I want to do it as bellow

      function openWindowWithArg()
      {
      var myParam = window.dialogArguments;
      var param = document.getElementById('TextBox1');
      param.value = myParam.param;
      //<%bindAdvancedFilterData("1,2"); %>;
      <%bindAdvancedFilterData(param.value); %>;
      }

      Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

      S 1 Reply Last reply
      0
      • A Abdul Rahman Hamidy

        well, I am calling openWindowWithArg function in onload of body as bellow

        <body onload="openWindowWithArg();">

        and the function

        <%bindAdvancedFilterData("1,2"); %>;

        is asp.net function which I am calling it from javascript. How to pass javascript variables to asp.net method? which I want to do it as bellow

        function openWindowWithArg()
        {
        var myParam = window.dialogArguments;
        var param = document.getElementById('TextBox1');
        param.value = myParam.param;
        //<%bindAdvancedFilterData("1,2"); %>;
        <%bindAdvancedFilterData(param.value); %>;
        }

        Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

        S Offline
        S Offline
        sashidhar
        wrote on last edited by
        #4

        To My knowledge use hidden control for that .I mostly uses that. Its Only a suggestion . http://www.dotnetcurry.com/ShowArticle.aspx?ID=203[^] If this the way you dont want please ignore..!

        LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

        A 1 Reply Last reply
        0
        • S sashidhar

          To My knowledge use hidden control for that .I mostly uses that. Its Only a suggestion . http://www.dotnetcurry.com/ShowArticle.aspx?ID=203[^] If this the way you dont want please ignore..!

          LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

          A Offline
          A Offline
          Abdul Rahman Hamidy
          wrote on last edited by
          #5

          thanks for reply, well I am not doing postback, If you I call that function in body load. If I do post back then Its possible to do it but since I am looking to do it only in body load.

          Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

          S 1 Reply Last reply
          0
          • A Abdul Rahman Hamidy

            Dear All, I am looking for a way where I want to pass javascript variable to asp.net function bellow is what I am doing right now

            function openWindowWithArg()
            {
            var myParam = window.dialogArguments;
            var param = document.getElementById('TextBox1');
            param.value = myParam.param;
            <%bindAdvancedFilterData("1,2"); %>; //this works fine
            <%bindAdvancedFilterData(param.value); %>; //this doesnt work, I want to do it this way
            }

            any ideas how i can pass param.value to the asp.net method bindAdvancedFilterData()?, I can do this using query string and session but May be it should be possible to do it like this?

            Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

            M Offline
            M Offline
            Mogamboo_Khush_Hua
            wrote on last edited by
            #6

            Developers in Afghanistan strange

            A 1 Reply Last reply
            0
            • A Abdul Rahman Hamidy

              Dear All, I am looking for a way where I want to pass javascript variable to asp.net function bellow is what I am doing right now

              function openWindowWithArg()
              {
              var myParam = window.dialogArguments;
              var param = document.getElementById('TextBox1');
              param.value = myParam.param;
              <%bindAdvancedFilterData("1,2"); %>; //this works fine
              <%bindAdvancedFilterData(param.value); %>; //this doesnt work, I want to do it this way
              }

              any ideas how i can pass param.value to the asp.net method bindAdvancedFilterData()?, I can do this using query string and session but May be it should be possible to do it like this?

              Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

              M Offline
              M Offline
              Mogamboo_Khush_Hua
              wrote on last edited by
              #7

              Use Ajax

              1 Reply Last reply
              0
              • A Abdul Rahman Hamidy

                thanks for reply, well I am not doing postback, If you I call that function in body load. If I do post back then Its possible to do it but since I am looking to do it only in body load.

                Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

                S Offline
                S Offline
                sashidhar
                wrote on last edited by
                #8

                Then the other approach is using webservice Refer this article..! http://www.asp.net/AJAX/Documentation/Live/Tutorials/ConsumingWebServicesWithAJAXTutorial.aspx[^]

                LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                1 Reply Last reply
                0
                • M Mogamboo_Khush_Hua

                  Developers in Afghanistan strange

                  A Offline
                  A Offline
                  Abdul Rahman Hamidy
                  wrote on last edited by
                  #9

                  thanks for your strange, I think It shouldn't be strange. using Ajax is the simplest way which I am not willing to use.there are other solutions like using QueryString and Sesstion which I can use. but I thought of using javascript which I think this could be impossible.

                  Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

                  M 1 Reply Last reply
                  0
                  • A Abdul Rahman Hamidy

                    thanks for your strange, I think It shouldn't be strange. using Ajax is the simplest way which I am not willing to use.there are other solutions like using QueryString and Sesstion which I can use. but I thought of using javascript which I think this could be impossible.

                    Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

                    M Offline
                    M Offline
                    Mogamboo_Khush_Hua
                    wrote on last edited by
                    #10

                    pagemethods in asp.net ajax , help u to call any function from aspx page in code page just google pagemethods

                    A 1 Reply Last reply
                    0
                    • S sashidhar

                      Why dont u use hidden field..? are u trying to call a method? what is bindAdvancedFilterData()? in here..!

                      LatestArticle :Log4Net Why Do Some People Forget To Mark as Answer .If It Helps.

                      N Offline
                      N Offline
                      Not Active
                      wrote on last edited by
                      #11

                      Because you don't always need to use a hidden field.


                      I know the language. I've read a book. - _Madmatt

                      1 Reply Last reply
                      0
                      • M Mogamboo_Khush_Hua

                        pagemethods in asp.net ajax , help u to call any function from aspx page in code page just google pagemethods

                        A Offline
                        A Offline
                        Abdul Rahman Hamidy
                        wrote on last edited by
                        #12

                        thanks for reply, You are asking me to use asp.net ajax and I am saying, I am in an envoirnment where no ajax should be used. every thing should be done through javascript and c#.

                        Abdul Rahaman Hamidy Database Developer Kabul, Afghanistan

                        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