OnClick event won't fire

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • -Karl

    OnClick event won't fire

    Snippet: http://www.nomorepasting.com/getpast...ngoverride=asp

    Line 37 is where I am having the problem. I can't get the onclick
    event to fire off. Yet line 16 works like it's supposed to. How do I
    get my onclick event to work? I tried changing it from onclick to
    onserverclick but that had no effect.


    Thanks!

  • -Karl

    #2
    Re: OnClick event won't fire

    It appears that my code will not accept my using ANY asp.net controls
    so I'm stuck with using html controls instead. Not a big deal bt I do
    have a bigger issue. I need to pass my JS variable into ASP.net.
    passing asp.net variables to JS is easy but not the other way around.
    Any ideas on how to do this? I am beginning to think a cookie would
    be the easiest way. Yea, I am already looking into AJAX but that's
    something else that I am not ready to understand at this time.

    Thanks!

    Comment

    • Alexey Smirnov

      #3
      Re: OnClick event won't fire

      On Jul 5, 7:38 pm, -Karl <dino...@gmail. comwrote:
      It appears that my code will not accept my using ANY asp.net controls
      so I'm stuck with using html controls instead. Not a big deal bt I do
      have a bigger issue. I need to pass my JS variable into ASP.net.
      passing asp.net variables to JS is easy but not the other way around.
      Any ideas on how to do this? I am beginning to think a cookie would
      be the easiest way. Yea, I am already looking into AJAX but that's
      something else that I am not ready to understand at this time.
      If you have a postback you can set a hiddenfield

      Comment

      • -Karl

        #4
        Re: OnClick event won't fire

        In a nutshell, I am making a custom map using Google's map API / SDK.
        I have my map working but now I am trying to add more functionality to
        it, in this case a search feature.

        Google maps uses JS very heavily and some AJAX as well (Something new
        for me to learn). The menu system is based off some fanncy DIV's and
        rendered client side using JS. As such, my ASP:INPUT control won't
        render for some reason so I am using abasic HTML Input control
        instead. What I am trying to do is fire off the OnClick event and
        pass the input to my asp control so I can perform a lookup and search
        against my DB. The OnClick event gets fired off in a JS function and
        there lies my issue.

        I'll post my page when I get home so you have a clear idea of what I
        am facing. I know my code isn't the cleanest. Please understand,
        I've been piecing together pieces from all over the net trying to get
        this to work.

        Thank you for all your help...
        -Karl



        Comment

        • -Karl

          #5
          Re: OnClick event won't fire

          K, here is my updated code:



          Line 72 is where the input control is. I know I have the runas=server
          option in it (I forgot to remove it before pasting).

          The Onclick event fires up the JS function Fou() which can read the
          HTML Input control value. I was playing around trying to see if maybe
          I could store that value into a cookie to be read by ASP but there
          seems to be some difference between how each language creates cookies
          so I am nt able top pass the value via cookie. So now I am looking
          into having JS write to a file just to have ASP read that file and
          pass the variable on. There has to be some easier method here but I
          can't find ANY working examples wehich is driving me nuts!

          I keep hearing AJAX and I understand it sends partial page info to the
          server instead of the entire page. Is this really the only way to
          pass a JS variable to ASP???

          I'm looking over http://www.w3schools.com/ajax/ajax_example.asp. This
          might clue me in unless you can think of another method? It's a bit
          of code but maybe this is what I need after all??



          Comment

          • =?Utf-8?B?U2VyZ2V5IFBvYmVyZXpvdnNraXk=?=

            #6
            Re: OnClick event won't fire

            Karl,

            I cannot find in the code provided how v string ends up on the browser. In
            your fou js function you can populate a hidden input (with runat='server' and
            id) and then its value can be read on the server by your ASP.Net


            "-Karl" wrote:
            K, here is my updated code:

            >
            >
            Line 72 is where the input control is. I know I have the runas=server
            option in it (I forgot to remove it before pasting).
            >
            The Onclick event fires up the JS function Fou() which can read the
            HTML Input control value. I was playing around trying to see if maybe
            I could store that value into a cookie to be read by ASP but there
            seems to be some difference between how each language creates cookies
            so I am nt able top pass the value via cookie. So now I am looking
            into having JS write to a file just to have ASP read that file and
            pass the variable on. There has to be some easier method here but I
            can't find ANY working examples wehich is driving me nuts!
            >
            I keep hearing AJAX and I understand it sends partial page info to the
            server instead of the entire page. Is this really the only way to
            pass a JS variable to ASP???
            >
            I'm looking over http://www.w3schools.com/ajax/ajax_example.asp. This
            might clue me in unless you can think of another method? It's a bit
            of code but maybe this is what I need after all??
            >
            >
            >
            >

            Comment

            • -Karl

              #7
              Re: OnClick event won't fire

              sorry for being so dumb about this but I'm still confused. I don't
              see how this would be any different. You are saying that I need to
              pass the variable from my HTML input to my hidden HTML input with a
              runas=server??

              I'm heading home soon and I'll give it a try and see what happens. My
              head is in the clouds today.


              On Jul 6, 1:08 am, Sergey Poberezovskiy
              <SergeyPoberezo vs...@discussio ns.microsoft.co mwrote:
              Karl,
              >
              I cannot find in the code provided how v string ends up on the browser. In
              your fou js function you can populate a hidden input (with runat='server' and
              id) and then its value can be read on the server by your ASP.Net

              Comment

              • Alexey Smirnov

                #8
                Re: OnClick event won't fire

                On Jul 6, 10:16 pm, -Karl <dino...@gmail. comwrote:
                sorry for being so dumb about this but I'm still confused. I don't
                see how this would be any different. You are saying that I need to
                pass the variable from my HTML input to my hidden HTML input with a
                runas=server??
                >
                I'm heading home soon and I'll give it a try and see what happens. My
                head is in the clouds today.
                >
                First of all, you cannot call a server code from client script like
                this. From what I see in code, v is executed on the server inside a
                client js-script. Regarding your first question, why submit() worked
                inside <% %and not onClick event. It works in the former case
                because you call it correctly on a <% server %while in the latter
                you tried to execute it as a client script. I am sorry that I didn't
                realize this before.

                The code should be following

                <input id="Submit1" type='submit' value='Find' onserverclick=" submit"
                runat='server'/>


                In case you want to use ASP.NET control you might have

                <asp:Button id="Submit1" onclick="submit " text="Find" runat="server" /
                >
                Note, that submit() method should be modified too (the signature):
                Sub submit(sender As Object, e As System.EventArg s)

                In case you will need a client script from an ASP.NET control, you
                should use OnClientClick event, e.g.

                <asp:Button runat="server" OnClientClick=" ClientJS();"... .

                Hope it helps to get your code working

                Regarding Google Maps. There are very good examples of code in SDK,
                did you check it?

                Comment

                • -Karl

                  #9
                  Re: OnClick event won't fire

                  Hope it helps to get your code working
                  >
                  Regarding Google Maps. There are very good examples of code in SDK,
                  did you check it?


                  I've tried using a .net button but it doesn't get rendered (gets
                  processed as text) so then I tried using the runat = server as you
                  mentioned but then I ran into errors. I forgot what it said but I can
                  post it later. I then found a nice tutorial on AJAX from w3schools
                  that I started to modify but as soon as I started to put my connect
                  string in the asp page, it bugged out on me.

                  I'll be looking thru the SDK perhaps tonight. I was looking at some
                  of their AJAX APIs, trying to get an idea on this. I was really
                  hoping to avoid doing postback but if I need to, I will have to design
                  my age around that. Not sure how that will work out though.

                  My head is killing me. I can't figure out why this has to be so
                  hard.

                  Again, thank you for all your help on this. I'm going to have a great
                  laugh at myself when it works. I'll have to send you a thank you card
                  or something.



                  Comment

                  Working...