RE: CustomValidator
- From: Morris Neuman <Morris@xxxxxxxxxxxxx>
- Date: Wed, 4 Feb 2009 08:30:08 -0800
Hi Allen,
Tried as suggested. However I get error during the update process. When I
enter Edit it works, when I select Update I get this error.
error "Microsoft JScript runtime error: Object required"
on line "var clientid = document.getElementById("hidden1").value"
I tried using the gridview1_itemUpdating script similar to the
textbox3_prerender but the update goes directly to the jscript.
What am I doing wrong?
How is validation done normally, custom validating the values between 2 or
more fields? This client side validation seems quite complex for 1 field, I
cannot imaging maintaining for additional fields. Is this complicated as I
have each field in its own template in a gridview? Is a better design to
keep all fields as a single template field (I loose the sorting or would then
have to do some manual work around).
I thought field validations would be so simple. Your help and advice are
much appreciated.
I emailed you the page code.
--
Thanks
Morris
"Allen Chen [MSFT]" wrote:
Hi Morris,.
Thanks for the update. I think you can try following steps to solve this
problem:
1. Add the PreRender event handler for TextBox3:
<asp:TextBox onprerender="TextBox3_PreRender" ID="TextBox3" …
protected void TextBox3_PreRender(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
this.hidden1.Value = tb.ClientID;
}
2. Add following code above the <asp:GridView>
<input type="hidden" runat="server" id="hidden1" />
<script type="text/javascript">
function NotfType_RecNo(sender, args) {
var clientid = document.getElementById("hidden1").value;
var tb3 = document.getElementById(clientid);
var tb3Value = tb3.value;
var ddl1Value = args.Value;
if (ddl1Value == "6")
{
if (tb3Value == "0")
{
args.IsValid = true;
}
else
{
args.IsValid = false;
}
}
}
</script>
Regards,
Allen Chen
Microsoft Online Support
- Follow-Ups:
- RE: CustomValidator
- From: Allen Chen [MSFT]
- RE: CustomValidator
- References:
- CustomValidator
- From: Morris Neuman
- RE: CustomValidator
- From: Allen Chen [MSFT]
- RE: CustomValidator
- From: Morris Neuman
- RE: CustomValidator
- From: Allen Chen [MSFT]
- RE: CustomValidator
- From: Morris Neuman
- RE: CustomValidator
- From: Allen Chen [MSFT]
- CustomValidator
- Prev by Date: Re: DropDownList Input
- Next by Date: RE: CustomValidator
- Previous by thread: RE: CustomValidator
- Next by thread: RE: CustomValidator
- Index(es):
Relevant Pages
|