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.

Line break problem in ASPNET AJAx


I am using ASP.NET AJAx 1.0 Framework.

The page is diplayed perfectly first time. But after a asynchronous post back an extra line added between the Header and the user control.

And no Styling related operations are done in the postback call.

I have compared the HTML that is generated before and after the call. But both are identical.

And I think the reason is that we cant see the modification made by the Ajax Asynchonous calls to the HTML file at the client side.

Does it possible to see the modified HTML code in the browser after a Ajax call to the server?

I don't know the exact solution to your problem, but, If I were you, I would use Fiddler

http://www.fiddlertool.com/

to see what's going on. Fiddler is an excellent HTTP debugging proxy, that monitors each and everyone HTTP request.


Fiddler's good for seeing the reqeust/response. IE Dev toolbar or Firebug are essential for seeing the 'live' DOM.


And this line break problem appears only in IE. Its working fine in Firefox 1.5.


Hi,

There are some useful tools in our daily development work.Such as:

IE: Fidder、IE Dev Toolbar、Instance source、HttpWatch、Web Development Helper(especially for UpdatePanel)

Firefox: Firebug

Hope it helps!

Linebreak appears after update panel submits

I wrote a control that would allow a user to click on a label, and then edit it the value, and send back the new value to the server via an update panel.

However, the first time the value is sent to the server, a line break appears right above the text box, i dont think this is a css error, i can't seem to figure out what is causing it by examining the DOM. This only appears in IE, not Firefox, Any ideas?

Here's the mark up for the Control

<%@dotnet.itags.org. Control Language="VB" AutoEventWireup="false" CodeFile="QuickEditLabel.ascx.vb" Inherits="QuickEditLabel" %><script type="text/javascript"> function<%=Me.hidCurrentFileId.ClientID%>updateNumber(param) { var hiddenField = document.getElementById("<%=hidCurrentFileId.ClientID%>"); hiddenField.value = param; __doPostBack('<%=hidCurrentFileId.ClientID%>',''); } function QuickEditSwap(hideMe, showMe) { showMe.style.display = 'none'; hideMe.style.display = 'inline'; }</script><asp:HiddenField ID="hidCurrentFileId" runat="server" Value="" /><asp:UpdatePanel ID="updPanel" UpdateMode="Conditional" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="hidCurrentFileId" EventName="ValueChanged" /> </Triggers> <ContentTemplate>   <asp:Label ID="Label1" runat="server" CssClass="QuickEditText" ToolTip="Click to Edit"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" CssClass="QuickEditTextBox" Width="93px"></asp:TextBox> </ContentTemplate></asp:UpdatePanel>

Here's the Code behind for the control

PartialClass QuickEditLabelInherits System.Web.UI.UserControlPrivate myTextAs String Public Property Text()Get Return myTextEnd Get Set(ByVal value) myText = valueEnd Set End Property Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.LoadIf Not IsPostBackThen Me.Text ="33"Else Me.Text =Me.TextBox1.TextEnd If Me.TextBox1.Attributes.Add("onchange",Me.hidCurrentFileId.ClientID +"updateNumber(getElementById('" + Me.TextBox1.ClientID + "').value)") Me.Label1.Attributes.Add("onclick", "QuickEditSwap(getElementById('" + Me.TextBox1.ClientID + "'), getElementById('" + Me.Label1.ClientID + "'))")End Sub Protected Sub Page_PreRender(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.PreRenderMe.Label1.Text =Me.TextMe.TextBox1.Text =Me.TextEnd SubEnd Class

Here's the css i'm using for the control

 .QuickEditText {font-family: Verdana;} .QuickEditText:hover {text-decoration: underline; font-family: Verdana; cursor: pointer} .QuickEditTextBox {display: none; font-family:Verdana;}

Thanks in advance for any suggestions,

This is happening because of the default setting of the UpdatePanel's RenderMode property - which will render its contents into a <div> the first time. Try changing it to "Inline" so that it will instead render a <span> element.

Lines and Arrows with Ajax

Hi,

I am trying to create a CASE tool(UML diagrams) on Web using ASP.NET 2.0 andAjax(Atlas). The problem is that I do not know how to create lines and arrows (links between elements).


Is it posible?

Please, help.

JavaScript is very limited to images. SVG and Canvas is what you would have to look into.

Eric

Link Button as trigger not firing

So I have a link button that is created here...

 LinkButton hide =new LinkButton(); hide.Text ="(hide)"; hide.Click +=new EventHandler(this.hide_Click); hide.ID ="hide" + deviceID;

which is later added to a table cell which is added to a table row which is added to a table. This table is what my function returns (the functions basically builds the table)

From where the function is called I have this code to create a trigger using the linkbutton hide, then add that trigger to the update panel that i am putting the newley created table in...

 AsyncPostBackTrigger trig =new AsyncPostBackTrigger(); ((UpdatePanel)tempTable.Parent.Parent).ContentTemplateContainer.Controls.Add(childTable); trig.ControlID = childTable.Rows[0].Cells[1].Controls[1].UniqueID; trig.EventName ="Click"; ((UpdatePanel)childTable.Parent.Parent).Triggers.Add(trig);

I have tried making the controlID both the unique ID and just the ID and neither work. I know that my just for testing my hide_click function is simple...

private void hide_Click(object sender, EventArgs e) { txtOutput.Text ="IT WORKED!"; }

I know the hide_Click function works because i attached it to other buttons in other tables and it executes fine.

Does anyone know if I am doing something wrong because I cannot seem to figure this out.

Thanks

Hi,

what issue are you experiencing? A full postback instead of an async postback? Or the "IT WORKED!" text isn't displayed? In this case, did you put the Label inside an UpdatePanel?


There is no postback at all. The txtOuput is inside an update panel. It works fine when triggered from other buttons that were added to my page the same way I am adding my link button, but something is acting up. Im not sure if there is a problem with where I am adding the trigger so I am going to try defining the trigger at the same place in code as where I am defining the link button to see if that helps, but i doubt that will change anything.


Ok this is really starting to mess with my head. I have noticed now that when i click on my button, the textbox txtOutput refreshes, but still displays the text that was already there, instead of getting the text from the hide_Click function. This is weird though because when I point other buttons to my hide_Click function, they fire it perfectly and the text box updates. I am confussed


Hi,

Please refer to this:

http://ajax.asp.net/docs/mref/T_System_Web_UI_AsyncPostBackTrigger.aspx

Programmatically adding AsyncPostBackTrigger controls is not supported. Use the RegisterAsyncPostBackControl(Control) method of the ScriptManager control to programmatically register a postback control, and then call the Update() method of the UpdatePanel when the control posts back.

Please try as the above documentation described. If still fails, please post a self-sufficient repro.


great thanks, ill take a look. I was all excited because I was able to programatically add asyncpostback trigers to some update panels, I did this at the time the panels were being created and it worked fine, I guess there are some situations where it just doesnt work though.


so it turns out the trigger is working fine, the only problem is that my hide_Click event isnt being fired. I have had this problem before where having certain settings enabled for different controls cause the controls .click event not to work properly, now its just a matter of finding out what is causing this problem

link button inside update panel causes post back

I have a linkbutton inside the update panel. I registered it with AsyncPostBackTrigger, but when I click that link button, the whole page is refreshed instead of that update panel, what could I have gone wrong?

Check the EnablePartialRendering="true" of ScriptManager is et or not ?

Also check UpdateMode="Conditional" of UpdatePanel is set or not ?

link buttons in user control not recognised by updatePanel

Hello...

I have a usercontol that has some linkbuttons.....and an updatePanel...i put the linkbutton ID's in the Trigger section of the updatePanel, but I'm getting an error that the updatePanel does not recognise the button ID's I have passed in...

how do I fix this? thanks

Hi,

Update Panel is not gonna recognize those link buttons because they are inside of usercontrol. You need to create user control event for each link button event. For example,

CustomControl.ascx

<%@. Control Language="C#" AutoEventWireup="true" CodeFile="CustomControl.ascx.cs" Inherits="CustomControl" %>
<asp:LinkButton ID="lnkTest" runat="server" OnClick="lnkTest_Click">Test Button</asp:LinkButton

CustomControl.ascx.cs

public partial class CustomControl : System.Web.UI.UserControl
{
public delegate void TestHandler(object sender, EventArgs e);
public event TestHandler LinkClicked;

protected void Page_Load(object sender, EventArgs e)
{

}
protected void lnkTest_Click(object sender, EventArgs e)
{
if (LinkClicked != null)
LinkClicked(this, new EventArgs());
}
}

test.aspx

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="CustomControl1" EventName="DoYourBussiness" />
</Triggers>
<ContentTemplate>
<uc1:CustomControl ID="CustomControl1" runat="server" OnLinkClicked="DoYourBussiness" />
</ContentTemplate>
</asp:UpdatePanel


Hi,

thanks for this, how about for normal hyperlinks?... (instead of linkButons)... can something similar be done?

thanks


Hi,

Normal hyperlinks do not have OnClick event. LinkButton looks the same as HyperLink, but has OnClick event.