469,904 Members | 1,921 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

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!

Jul 5 '07 #1
8 2352
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!

Jul 5 '07 #2
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

Jul 5 '07 #3
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

Jul 6 '07 #4
K, here is my updated code:
http://www.nomorepasting.com/getpast...ngoverride=asp
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??

Jul 6 '07 #5
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:
http://www.nomorepasting.com/getpast...ngoverride=asp
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??

Jul 6 '07 #6
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
<SergeyPoberezovs...@discussions.microsoft.comwrot e:
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
Jul 6 '07 #7
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'/>
http://msdn2.microsoft.com/en-us/lib...rverclick.aspx

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.EventArgs)

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?

Jul 7 '07 #8
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.

Jul 9 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by moondaddy | last post: by
2 posts views Thread by Sam Miller | last post: by
7 posts views Thread by Ryan Ternier | last post: by
5 posts views Thread by Stuart Shay | last post: by
11 posts views Thread by Daz | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.