473,378 Members | 1,504 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,378 software developers and data experts.

CustomValidator and jscript confirm()

SS
Hi newbie ASP.NET coder here...

Can someone tell me what I'm missing or what I'm doing wrong here?

I'm trying to validate based on a javascript confirm. The confirm box is
just an ok/cancel. Whether I press ok or cancel, I get the invalid page.
Help?

===================================>>

<script runat="server">
Private sub DoSomething(s as Object,e As EventArgs)
dim msg as string
if (Page.IsValid) then
label1.Text = "Did something"
Else
label1.Text = "Invalid something"
End if
end sub
</script>

<script LANGUAGE="JavaScript">
function confirmSubmit(source, Value)
{
var btMsg = "Client Validator"
var name=confirm(btMsg)
if (name==true)
{
Value.IsValid = True;
}
else
{
Value.IsValid = False;
}
}
</script>

<html>
<body>

<form runat="server">
<asp:TextBox id="tbUserID" TextMode="multiline" runat="server" /><br />
<asp:Button OnClick="DoSomeThing" Text="Submit" runat="server" />

<asp:CustomValidator id="ValidateUserID" runat="server"
ControlToValidate="tbUserID"
ClientValidationFunction="confirmSubmit"
Display="Dynamic"
Text="Invalid User ID"
Font-Name="verdana" Font-Size="10pt" runat="server"/>

<p><asp:label id="label1" runat="server" /></p>
</form>

</body>
</html>
Nov 18 '05 #1
2 3360
Quick check: Change True to true and False to false when assigning values to
Value.IsValid and then try.

"SS" <SS@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
Hi newbie ASP.NET coder here...

Can someone tell me what I'm missing or what I'm doing wrong here?

I'm trying to validate based on a javascript confirm. The confirm box is
just an ok/cancel. Whether I press ok or cancel, I get the invalid page.
Help?

===================================>>

<script runat="server">
Private sub DoSomething(s as Object,e As EventArgs)
dim msg as string
if (Page.IsValid) then
label1.Text = "Did something"
Else
label1.Text = "Invalid something"
End if
end sub
</script>

<script LANGUAGE="JavaScript">
function confirmSubmit(source, Value)
{
var btMsg = "Client Validator"
var name=confirm(btMsg)
if (name==true)
{
Value.IsValid = True;
}
else
{
Value.IsValid = False;
}
}
</script>

<html>
<body>

<form runat="server">
<asp:TextBox id="tbUserID" TextMode="multiline" runat="server" /><br />
<asp:Button OnClick="DoSomeThing" Text="Submit" runat="server" />

<asp:CustomValidator id="ValidateUserID" runat="server"
ControlToValidate="tbUserID"
ClientValidationFunction="confirmSubmit"
Display="Dynamic"
Text="Invalid User ID"
Font-Name="verdana" Font-Size="10pt" runat="server"/>

<p><asp:label id="label1" runat="server" /></p>
</form>

</body>
</html>
Nov 18 '05 #2
SS
Thanks...worked a treat...Too much VB will do this to you ;)

SS

"Shiva" wrote:
Quick check: Change True to true and False to false when assigning values to
Value.IsValid and then try.

"SS" <SS@discussions.microsoft.com> wrote in message
news:B0**********************************@microsof t.com...
Hi newbie ASP.NET coder here...

Can someone tell me what I'm missing or what I'm doing wrong here?

I'm trying to validate based on a javascript confirm. The confirm box is
just an ok/cancel. Whether I press ok or cancel, I get the invalid page.
Help?

===================================>>

<script runat="server">
Private sub DoSomething(s as Object,e As EventArgs)
dim msg as string
if (Page.IsValid) then
label1.Text = "Did something"
Else
label1.Text = "Invalid something"
End if
end sub
</script>

<script LANGUAGE="JavaScript">
function confirmSubmit(source, Value)
{
var btMsg = "Client Validator"
var name=confirm(btMsg)
if (name==true)
{
Value.IsValid = True;
}
else
{
Value.IsValid = False;
}
}
</script>

<html>
<body>

<form runat="server">
<asp:TextBox id="tbUserID" TextMode="multiline" runat="server" /><br />
<asp:Button OnClick="DoSomeThing" Text="Submit" runat="server" />

<asp:CustomValidator id="ValidateUserID" runat="server"
ControlToValidate="tbUserID"
ClientValidationFunction="confirmSubmit"
Display="Dynamic"
Text="Invalid User ID"
Font-Name="verdana" Font-Size="10pt" runat="server"/>

<p><asp:label id="label1" runat="server" /></p>
</form>

</body>
</html>

Nov 18 '05 #3

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

Similar topics

7
by: jcpmeticulus | last post by:
Hi I've spent the last day or so debugging a problem with a CustomValidator and am now totally stumped! Basically I use a number of CustomValidator's on my page, but have cut this down now to...
1
by: Jon Davis | last post by:
I have a CustomValidator control, to which I've assigned a Javascript function name in the ClientValidationFunction property of the control. Example client function (Jscript): <script>...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: SMG | last post by:
Hi All. My forms has two textboxes, 1 username, 2 password. Both has requiredfield validator it works fine when there is no input in these textboxes. And the errorMsg is shown in...
3
by: Craig G | last post by:
hi, im only learning javascript, i have this little code snippet that i wish to use. basically the code-behind page will display a little jscript confirm message box Public Sub...
10
by: SergioT | last post by:
Hi I wanna to create a jscript function that sets the value of a textbox into a datagrid, But the problem is How can I obtain the name of the textbox and send it to my jscript function???? The...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
0
by: JT | last post by:
In looking around on the internet to find out how to use a "messagebox"-like window on a webform, I have come across a few examples of how to do so from the "onclick" event of a button. In my...
15
by: zz12 | last post by:
Hello, would anyone be able to confirm that 'jscript.dll' is a necessary file for an .asp page on IIS 5.0 to use the <script language="JavaScipt" runat="SERVER"code? It looks like the code in this...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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$) { } ...
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...

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.