Wednesday, March 28, 2012

Line 5909 Javascript Error

Error Message:

Line:5909
Char:12
Error: Sys.ArgumnetUndefinedException:Value cannot be undefined. Parameter name:id

Code:

I write an mask customer validator control And use this control in ajax updatepanel control. It will show javascript error.

Below is my code:

maskedVad.ClientValidationFunction = this._CallbackFailFunction;
vce4Mask = new ValidatorCallbackExtender();
vce4Mask.TargetControlID = maskedVad.ID;
vce4Mask.HighlightCssClass = this._HighlightCssClass;
vce4Mask.CallbackFailFunction = this._CallbackFailFunction;
vce4Mask.CallbackControlID = this.ID;
Controls.Add(vce4Mask);

This is apparently a bug in the Ajax RTM that will be fixed. In the meantime you should check out this link for a solution:
http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx


I replaced validators.js file and added the tagmapping in web.config. but the bug still existed. Can someone give me more suggestions?


Hi Wallance,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Best Regards,

Jonathan


I do a custom extendtextbox webcontrol.

TextBox txt = new TextBox()

req = new RequiredFieldValidator();
req.ControlToValidate = this.ID;
req.ID = this.ID + "_req";
req.Display = ValidatorDisplay.None;
string sRoot = HttpContext.Current.Request.ApplicationPath;
req.ErrorMessage = this.RequiredErrorMsg;
req.EnableClientScript = (this.ClientScript.ToLower() != "false");
Controls.Add(req);

vce4Required = new ValidatorCallbackExtender();
vce4Required.TargetControlID = req.ID;
vce4Required.HighlightCssClass = this._HighlightCssClass;
vce4Required.CallbackFailFunction = this._CallbackFailFunction;
vce4Required.CallbackControlID = this.ID;

See the aspx

<asp:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<contenttemplate>

<asp:Table runat="server" id="appInfoTable">
</asp:Table>

</contenttemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnadd" EventName="Click" />
</Triggers>


</asp:UpdatePanel>

addbtn_click

protected void CreateRows(int Rowcount)
{
int i = 0;
for (i = 0; i < Rowcount; i++)
{
TableRow tr = new TableRow();

TableCell tc = new TableCell();
extendtextbox txt = CreateTextBox(i);
tc.Controls.Add(txt);

tr.Cells.Add(tc);
appInfoTable.Rows.Add(tr);
}
}

private extendtextbox CreateTextBox(int loop)
{
extendtextbox txtbox = new extendtextbox ();
txtbox.Validate = "required";

txtbox.ID = "mytextbox" + loop.ToString();
txtbox.Label = "acc_accountInfoForm_label_loginInfo";
txtbox.RequiredErrorMsg = "only for test";
txtbox.Type = extendtextbox .Text;
return txtbox;
}

Because the code is very long. Include one webcontrol and one page.

Thank you very much.


Hi Wallance,

Please add break point at "req = new RequiredFieldValidator(); req.ControlToValidate = this.ID;" and debug it step-by-step since the error propmt is "Sys.ArgumnetUndefinedException:Value cannot be undefined. Parameter name:id". Thanks.

Best Regards,

Jonathan.

No comments:

Post a Comment