472,779 Members | 2,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 4077
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: minstrel80232 | last post by:
Hi Everybody - I'm new to this group - I need a little help please, I am looking for a simple Javascript form I can use to sign people up for classes on a web site. I have never done a form...
7
by: AnnMarie | last post by:
My JavaScript Form Validation doesn't work at all in Netscape, but it works fine in IE. I made some of the suggested changes which enabled it to work in IE. I couldn't make all the changes...
72
by: Stephen Poley | last post by:
I have quite often (as have probably many of you) come across HTML forms with irritating bits of Javascript attached. The last straw on this particular camel's back was a large form I was asked to...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
6
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: ...
8
by: ryan | last post by:
that will make sure all fields are entered. make sure age is between 3- 99 and make sure the email is valid I had a decent search on google, nothing really comes up that is complete. I am...
8
by: nektir | last post by:
I have an external js file to validate a form and it works in IE and Opera, but not Mozilla Firefox. In Mozilla Firefox, the javascript console sasys "SearchForm" is not defined in the second...
2
by: mylo1968 | last post by:
Hello Experts, in the following link there is fine tool for javascript client-side form validation, as some of you I guess/hope know: ...
1
by: panuvin | last post by:
Hello all, I am working on a Winforms project that currently has a Datagrid to display the data from a Dataset (this can be easily changed to a Datagridview control). I know there are tooltips...
3
by: PrabodhanP | last post by:
I hv following javascript form validation code works in IE but not in Mozilla-Firefox ...please suggest <script type="text/javascript"> function IsNumeric(strString) // check for valid...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.