Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
strScript += "confirm(""" & Trim(Message) &
""");"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Any help is appreciated.
Thanks. 7 5192
Hi,
shil wrote:
Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
The "language" attribute is deprecated. You should use
type="text/javascript" instead.
strScript += "confirm(""" & Trim(Message) &
""");"
The "confirm" method returns a boolean. It's true if the user clicked
Yes, and false if he clicked No. You need to save this value in a variable
strScript += "var bAnswer = confirm(""" & Trim(Message) & """);"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Once the user's answer is saved in the "bAnswer" variable, you need to
transmit it to the server. There are many ways to do that.
- The easiest is probably to put the variable in a hidden form field and
then submit the form (using JavaScript). On the server, read the hidden
form field's value.
- You can use a query string, for example:
top.location = "mypage.aspx?answer=" + ( bAnswer ? "true" : "false" );
These two ways cause a callback to the server, so the page will be
refreshed.
A third way, which won't cause a callback, is to use some kind of Ajax.
In your case, a simple call using XmlHttpRequest would be sufficient. Or
else, you can use a web method.
HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
This link may help you to setup message and action communication between
server and client: http://www.usableasp.net/DeveloperPa...rAndClient.htm
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin
"shil" <jo******@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
strScript += "confirm(""" & Trim(Message) &
""");"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Any help is appreciated.
Thanks.
store the answer in a hidden field:
document.getElementById('fieldid').value = confirm('ok');
where fieldid is the id of the hidden field
-- bruce (sqlwork.com)
shil wrote:
Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
strScript += "confirm(""" & Trim(Message) &
""");"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Any help is appreciated.
Thanks.
No doubt you will have to store these in a hidden field if you don't want to
use a lot of Ajax here. As you said you don't want to attach this to a
button. So here's an example of handling a return value such as in
confirm(message), and using those values in server side code. http://www.codeproject.com/aspnet/Cl...nteraction.asp
"shil" <jo******@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
strScript += "confirm(""" & Trim(Message) &
""");"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Any help is appreciated.
Thanks. http://www.aspkey.net/aspkey/_blog/i...th=8&year=2006
"shil" <jo******@gmail.comwrote in message news:11**********************@48g2000cwx.googlegro ups.com...
Hi all,
Can any one direct me in how to use javascript confirm() function when
a condition is met from codebehind. I don't want to attach this to a
button. When I submit the page, I want to check some business rules,
and based on the response from the database, if the response is Yes, I
need to display a confirmation alert to user. When the user clicks ok,
then I should take an action, if not, exit out of the subroutine.
Below is the script I'm using in the Submit_Click() subroutine.
If Trim(Message) <"" Then
Dim strScript As String = "<script
language=JavaScript>"
strScript += "confirm(""" & Trim(Message) &
""");"
strScript += "</script>"
If (Not
Page.IsStartupScriptRegistered("clientScript")) Then
Page.RegisterStartupScript("clientScript",
strScript)
End If
End If
In the above code, I'm getting a message from the Sql database into
Message variable, and showing that to the user.
But I don't have a way to track what an user have selected from the
confirmation alert box.
Any help is appreciated.
Thanks.
Hi everyone,
I still can't find a solution to my problem.
can any one help me?
As I explained I can't register the event to button on page load
because I have to show the confirmation to user only after checking the
database. If the user click on Yes, I want to track that value and
continue in the server side script with out resubmitting the page.
Thanks.
Not sure exactly what you are asking.
What are you checking in the database?
Are you loading records and the conformation button depends on records being
present or a certain value?
Are you having problems registering the event on the button?
Are you looking for a way to call server side code from client side code
like using AJax or Ajax.Net?
Regards,
Brian K. Williams
"shil" <jo******@gmail.comwrote in message
news:11**********************@i12g2000cwa.googlegr oups.com...
Hi everyone,
I still can't find a solution to my problem.
can any one help me?
As I explained I can't register the event to button on page load
because I have to show the confirmation to user only after checking the
database. If the user click on Yes, I want to track that value and
continue in the server side script with out resubmitting the page.
Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Muhammad Abdullah |
last post by:
Hi
am having some problems with the javascript confirm.
i have it working fine on one page and it doesnt even pop up at the
other.
The code on the working page is,
private void...
|
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...
|
by: TJS |
last post by:
javascript "confirm" fires after deletion instead of before deletion.
how do I get this to stop the processing ?
code
==================
Sub ShowAlert(ByVal s As string)...
|
by: tshad |
last post by:
I have the following code that attaches a Javascript confirm box to my
checkbox. When I select the checkbox, the window comes up fine, but it
never executes the XfertoDefault_Click function when I...
|
by: TJ |
last post by:
Hi,
I would like to ask something to user after user submits the form...
I know I can ask user whehter they want to submit the form or not using
client-script code such as onClick or onSubmit by...
|
by: Dave |
last post by:
Hello all,
I have been able to use a Javascript alert box in my vb.net web application,
for example:
Dim msg As String = "Hello, world."
Dim alertScript As String = "<script...
|
by: tfsmag |
last post by:
Okay, I have a project management app i'm writing and in the left hand
menu i have a treeview control that is populated with each project...
in child nodes under each project node I have an "edit"...
|
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...
|
by: rn5a |
last post by:
I have gone through a no. of posts in this NewsGroup regarding my
problem but alas, couldn't come across one which would have helped me
in resolving the issue. My problem is this:
An ASPX Form...
|
by: Frinavale |
last post by:
Introduction
I've seen many questions asked about how to disable the browser's back button and in the past I've replied with "it's simply not possible". It's not a good idea to disable the back...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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...
|
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
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |