473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Javascript popup and server code

I don't know if this can be done. It is a coordination with my client side
vs my server side code.

I can create a popup fine:

Dim myNextButton As ImageButton =
CType(DataList1.Controls(DataList1.Controls.Count-1).FindControl("DownQuestion"),ImageButton)
myNextButton.Attributes.Add("onclick", "return confirm('Are you sure
you want finish this test?');")

This will put a popup on my button that will get processed before the page
posts. If they say "yes" the post happens, if "no", it doesn't.

If it posts, I am going to hide part of the page and show a congratulations
message.

My problem is that I need to check to see if a radiobutton has been pressed
first and one of my global values is set. This means I need to go to my
server side code to check this out and it is too late to attach the popup to
my button as it has already been pushed and the page is already in postback
mode.

Is there a way to do this?

Thanks,

Tom
Nov 19 '05 #1
2 1529
Hi Tom,

You could try something like this:

In your code behind put this in your declarations:

Protected WithEvents hidGlobal As System.Web.UI.HtmlControls.HtmlInputHidden

Change your onclick Attribute:

myNextButton.Attributes.Add("onclick", "return MyConfirm();")

Assign your global variable to the hidden field:

hidGlobal.Value = CStr(theglobalvariable)

Now in your .aspx page do this:

Add the input tag:

<input type="hidden" id="hidGlobal" name="hidGlobal" runat="Server">

Then add the JavaScript function:

function MyConfirm() {
if (document.getElementById("radiobuttonid").checked == true) {
if (document.getElementById("hidGlobal").value == "what it should")
{
return confirm('Are you sure you want finish this test?');
}
}
return false;
}

You'll probably need to change that around to correspond to the correct
logic for your radio buttons and global variables but that should set you on
the right track to accomplish what you are trying to do. If you have
anymore questions fire away and watch out for any typos I might've made.
Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I don't know if this can be done. It is a coordination with my client side vs my server side code.

I can create a popup fine:

Dim myNextButton As ImageButton =
CType(DataList1.Controls(DataList1.Controls.Count-1).FindControl("DownQuesti
on"),ImageButton) myNextButton.Attributes.Add("onclick", "return confirm('Are you sure
you want finish this test?');")

This will put a popup on my button that will get processed before the page
posts. If they say "yes" the post happens, if "no", it doesn't.

If it posts, I am going to hide part of the page and show a congratulations message.

My problem is that I need to check to see if a radiobutton has been pressed first and one of my global values is set. This means I need to go to my
server side code to check this out and it is too late to attach the popup to my button as it has already been pushed and the page is already in postback mode.

Is there a way to do this?

Thanks,

Tom

Nov 19 '05 #2
"Ken Dopierala Jr." <kd*********@wi.rr.com> wrote in message
news:uk**************@tk2msftngp13.phx.gbl...
Hi Tom,

You could try something like this:

In your code behind put this in your declarations:

Protected WithEvents hidGlobal As
System.Web.UI.HtmlControls.HtmlInputHidden

Change your onclick Attribute:

myNextButton.Attributes.Add("onclick", "return MyConfirm();")

Assign your global variable to the hidden field:

hidGlobal.Value = CStr(theglobalvariable)

Now in your .aspx page do this:

Add the input tag:

<input type="hidden" id="hidGlobal" name="hidGlobal" runat="Server">

Then add the JavaScript function:

function MyConfirm() {
if (document.getElementById("radiobuttonid").checked == true) {
if (document.getElementById("hidGlobal").value == "what it should")
{
return confirm('Are you sure you want finish this test?');
}
}
return false;
}

You'll probably need to change that around to correspond to the correct
logic for your radio buttons and global variables but that should set you
on
the right track to accomplish what you are trying to do. If you have
anymore questions fire away and watch out for any typos I might've made.
I'll play around with this.

I should be able to do everything but the "withevents" statement, as I am
not using code-behind at the moment.

Thanks,

Tom Good luck! Ken.

--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"tshad" <ts**********@ftsolutions.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
I don't know if this can be done. It is a coordination with my client

side
vs my server side code.

I can create a popup fine:

Dim myNextButton As ImageButton =

CType(DataList1.Controls(DataList1.Controls.Count-1).FindControl("DownQuesti
on"),ImageButton)
myNextButton.Attributes.Add("onclick", "return confirm('Are you
sure
you want finish this test?');")

This will put a popup on my button that will get processed before the
page
posts. If they say "yes" the post happens, if "no", it doesn't.

If it posts, I am going to hide part of the page and show a

congratulations
message.

My problem is that I need to check to see if a radiobutton has been

pressed
first and one of my global values is set. This means I need to go to my
server side code to check this out and it is too late to attach the popup

to
my button as it has already been pushed and the page is already in

postback
mode.

Is there a way to do this?

Thanks,

Tom


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: TeknoCat | last post by:
Hey everyone, I may be repeating myself here, but if someone sent a reply then I missed it, and I can't get Outlook Express to download any messages more than 2 days old. Anyway, I'm having a...
14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
6
by: szabelin | last post by:
Hello, I am trying to call a function inside the javascript block from asp.net during the postback (NOT button's OnClick event handler though). The javascript function creates new popup window. I...
12
by: Mark Fox | last post by:
Hello, I am attempting to do something very simple. I have a page MainPage.aspx and a popup window Popup.aspx. When users click on the linkbutton in the popup window I am looking to do some...
1
by: Jorge Ponte | last post by:
hi I have a Web User Control (ascx) - lets call it "My_WUC" - in a Web form. In that WUC I want have a textbox and a button. I want to click on the button and open a popup (I use javascript for...
6
by: tshad | last post by:
I am trying to set up a Javascript popup box that has a way of sending back a message to asp.net on how to process some data. At the moment I am just doing: ...
9
by: tshad | last post by:
This is from my previous post, but a different issue. I have the following Javascript routine that opens a popup page, but doesn't seem to work if called from an asp.net button. It seems to work...
2
by: Tim::.. | last post by:
Hi I'm trying to create a little application that shows an image of a user when you mouseover there details in a datagrid. The datagrid is populated from an Active Directory Database and I...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
16
by: Eric | last post by:
I have a user of a web application written in Java/JSP that is unable to login to the site simply because certain links on the page do not run when they are clicked. Other popups using Javascript...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.