471,066 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,066 software developers and data experts.

Javascript and vb.net web form (pop up)

Hello !!

I want a link on my vb.net web application, which when clicked, popUp's
up and shows a msg.
AFAIK, Javascript is the best way to go.

So I created an asp:hyperlink, and on its 'on click' event, I have
something like:
Page.RegisterStartupScript("myWinName", showAPopUp(messageString),
where, showAPopUp is a code-behind function which has
window.Open(....). messageString is a string that I am building when
the click event occurs.

I have 2 problems :
1) When the 'on Click' event fires, it posts back the page (I beleive,
its posting it to the server). But I am trying to use client sides
scripting to avoid server posts. Does Page.RegisterStartupScript post
data to the server ? If yes, is there a way I can do this without
posting it to the server ?

2) In the same link mentioned above, this is the sequence i am
following, which creates a problem.
i click the hyperlink, it opens a pop-up, i close it, go to next page.
Now, when I click IE's back button, instead of showing just the
previous page, it shows me the popup first. Is there a way I can avoid
this too ?

Thanks !!

Oct 23 '06 #1
3 4016
1) You have to circumvent the natural tendency of a hyperlink to link to
something. There are better controls to pop up with.
2) The back button occurs as that was the state of the page before it went
forward. Curing #1 will cure #2.

For my app, I used a linkButton with no href. I then add to the OnClick
event and everything is golden. No refresh of the page.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"Christina" <ch*********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
Hello !!

I want a link on my vb.net web application, which when clicked, popUp's
up and shows a msg.
AFAIK, Javascript is the best way to go.

So I created an asp:hyperlink, and on its 'on click' event, I have
something like:
Page.RegisterStartupScript("myWinName", showAPopUp(messageString),
where, showAPopUp is a code-behind function which has
window.Open(....). messageString is a string that I am building when
the click event occurs.

I have 2 problems :
1) When the 'on Click' event fires, it posts back the page (I beleive,
its posting it to the server). But I am trying to use client sides
scripting to avoid server posts. Does Page.RegisterStartupScript post
data to the server ? If yes, is there a way I can do this without
posting it to the server ?

2) In the same link mentioned above, this is the sequence i am
following, which creates a problem.
i click the hyperlink, it opens a pop-up, i close it, go to next page.
Now, when I click IE's back button, instead of showing just the
previous page, it shows me the popup first. Is there a way I can avoid
this too ?

Thanks !!

Oct 23 '06 #2

Christina wrote:
Hello !!
Hi
>
I want a link on my vb.net web application, which when clicked, popUp's
up and shows a msg.
AFAIK, Javascript is the best way to go.
Yep, javascript is about as good as it gets
>
So I created an asp:hyperlink, and on its 'on click' event, I have
something like:
Is there a reason for using asp:hyperlink rather than a simple HTML <a
href? i.e. is the link dynamically generated from code?

If memory servers me I think you can use onclientclick to call a
javascript function to poupup the window. e.g. onclientclick="return
showAPopUp(messageString);" and have showAPopUp return false to prevent
even bubbling. This would also prevent the back button causing the
window to reappear as it is managed client side and not by the server.

Page.RegisterStartupScript("myWinName", showAPopUp(messageString),
where, showAPopUp is a code-behind function which has
window.Open(....). messageString is a string that I am building when
the click event occurs.

I have 2 problems :
1) When the 'on Click' event fires, it posts back the page (I beleive,
its posting it to the server). But I am trying to use client sides
scripting to avoid server posts. Does Page.RegisterStartupScript post
data to the server ? If yes, is there a way I can do this without
posting it to the server ?

As mentioned above try not to use asp:hyperlink unless there is a
reason to do so, if you do use the onclientclick option rather than
onclick.
>
2) In the same link mentioned above, this is the sequence i am
following, which creates a problem.
i click the hyperlink, it opens a pop-up, i close it, go to next page.
Now, when I click IE's back button, instead of showing just the
previous page, it shows me the popup first. Is there a way I can avoid
this too ?
Using the above mentioned method should fix this.
>
Thanks !!
Your welcome.

Steve

Oct 23 '06 #3
Thanx guys for your help !!

Sorry, there was a typo error - I am using <asp:linkbutton
id=lbShowPopUpand NOT hyperlink.

When clicking on it, the vb.net code executed is below :

Private Sub lbShowPopUp_Click(...)
sMsgStr as string = "Some damn string with hyperlinks and many
formatting etc"
Page.RegisterStartupScript("newWin", popUpWindow(sMsgStr)
End Sub

popUpWindow(message) is in the code-behind, which does specific
formating of the page...
Jester98x, I am using <a onclick="popUpWindow('Some msg here')in some
cases in the same page. But the case in which I am using
<asp:linkbutton>, its a long string and also fetches some values from
config file (passing configs value to code behind, I havent used it),
so to avoid messing up code-behind, I am using vb.net code. I am open
to other suggestions too, if its possible in my scenario.
<asp:linkbutton id=lbShowPopUpwhen clicked, these are steps that are
executed:
1page_load
2) Private Sub lbShowPopUp_Click(...)

So the page refreshes. This is unlike <awhich doesnt refresh page.

Cowboy, didnt you encounter this problem ? You said u used something
similiar which dint refresh the page, was it -
attribues.add("onClick")... or something similar to lbShowPopUp_Click
()?

Thanks again!!
Chris

Jester98x wrote:
Christina wrote:
Hello !!

Hi

I want a link on my vb.net web application, which when clicked, popUp's
up and shows a msg.
AFAIK, Javascript is the best way to go.

Yep, javascript is about as good as it gets

So I created an asp:hyperlink, and on its 'on click' event, I have
something like:

Is there a reason for using asp:hyperlink rather than a simple HTML <a
href? i.e. is the link dynamically generated from code?

If memory servers me I think you can use onclientclick to call a
javascript function to poupup the window. e.g. onclientclick="return
showAPopUp(messageString);" and have showAPopUp return false to prevent
even bubbling. This would also prevent the back button causing the
window to reappear as it is managed client side and not by the server.

Page.RegisterStartupScript("myWinName", showAPopUp(messageString),
where, showAPopUp is a code-behind function which has
window.Open(....). messageString is a string that I am building when
the click event occurs.

I have 2 problems :
1) When the 'on Click' event fires, it posts back the page (I beleive,
its posting it to the server). But I am trying to use client sides
scripting to avoid server posts. Does Page.RegisterStartupScript post
data to the server ? If yes, is there a way I can do this without
posting it to the server ?


As mentioned above try not to use asp:hyperlink unless there is a
reason to do so, if you do use the onclientclick option rather than
onclick.

2) In the same link mentioned above, this is the sequence i am
following, which creates a problem.
i click the hyperlink, it opens a pop-up, i close it, go to next page.
Now, when I click IE's back button, instead of showing just the
previous page, it shows me the popup first. Is there a way I can avoid
this too ?

Using the above mentioned method should fix this.

Thanks !!

Your welcome.

Steve
Oct 24 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by minstrel80232 | last post: by
72 posts views Thread by Stephen Poley | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.