Asp.net| Tips
Introduction: Anthem is a very useful Ajax framework that supports ASP.net 1.1, 2.0.
Because all of the controls for the framework inherit from ASP.net's own server controls, the properties and behavior of almost all of these controls are preserved (except for the postback change to CallBack without refreshing calls). So the learning curve is very flat.
Today, I ran into a more troublesome debugging problem when I used anthem, as recorded here.
In the following code, I used a anthem.repeater control.
<asp:xmldatasource id= "XmlDataSource2" runat= "Server" xpath= "//needdocs/doc"
Enablecaching= "false" ></asp:XmlDataSource>
<table class= "MyTable" width= "100%" cellspacing= "0" cellpadding= "0" >
<anthem:repeater id= "Rptneeddocs" runat= "Server" datasourceid= "XmlDataSource2"
autoupdateaftercallback= "False" >
<HeaderTemplate>
<tr class= "Formtitle" >
<td>
Select </td>
<td>
File, drawing name </td>
<td>
should send </td>
<td>
Whether original </td>
<td>
Notes </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:checkbox id= "Chkdoc" runat= "Server" checked= "True"/>
<asp:hiddenfield id= "Hiddocid" runat= "server" Value= ' <%# XPath ("@Id")%> '/>
</td>
<td>
<asp:label id= "Lbldocname" runat= "server" text= ' <%# XPath ("@Name")%> '/>
</td>
<td>
<asp:textbox id= "txtquantity" runat= "server" text= ' <%# XPath ("@Quantity")%> ' width= '/>
</td>
<td>
<asp:radiobuttonlist id= "radiolist_isoriginal" runat= "server" Selectedvalue= ' <%# XPath ("@IsOriginal")%> '
repeatdirection= "Horizontal" >
<asp:listitem value= "True" > Original </asp:ListItem>
<asp:listitem value= "False" > Copy </asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:textbox id= "txtcomment" runat= "server" text= ' <%# XPath ("Comment")%> '/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</FooterTemplate>
</anthem:Repeater>
</table>
When this code is running, there are sometimes a JS error: "Unknown run-time error."
This error occurs only under certain circumstances and is normal in other similar cases.
Fortunately, VS 2005 provides very powerful client-side scripting debugging capabilities. I finally fixed the error to a line of code generated by anthem:
control.innerhtml = Result.controls[controlid];
After checking the relevant data, it is found that under IE, when assigning value to the InnerHTML attribute, the assigned value is checked. If it is not a formed, "Unknown run-time error" may occur.
So I judged anthem. The Repeater output of HTML is out of the question. From the two lines highlighted in the above code, you can see that the table tag is outside the Repeater. So Repeater itself outputs a series of TR, not a whole of the formed.
So I put the label of the table to the Repeater HeaderTemplate and FooterTemplate respectively, the problem solved.
(The reason why the table label was previously placed outside was because it was placed in HeaderTemplate and FooterTemplate, and it was not known why the VS designer could not switch to Design view.) and change it to solve the problem. )
After the successful modification, the code is as follows:
<asp:xmldatasource id= "XmlDataSource2" runat= "Server" xpath= "//needdocs/doc"
Enablecaching= "false" ></asp:XmlDataSource>
<anthem:repeater id= "Rptneeddocs" runat= "Server" datasourceid= "XmlDataSource2" autoupdateaftercallback= "False" >
<HeaderTemplate>
<table class= "MyTable" width= "100%" cellspacing= "0" cellpadding= "0" >
<tr class= "Formtitle" >
<td>
Select </td>
<td>
File, drawing name </td>
<td>
should send </td>
<td>
Whether original </td>
<td>
Notes </td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td>
<asp:checkbox id= "Chkdoc" runat= "Server" checked= "True"/>
<asp:hiddenfield id= "Hiddocid" runat= "server" Value= ' <%# XPath ("@Id")%> '/>
</td>
<td>
<asp:label id= "Lbldocname" runat= "server" text= ' <%# XPath ("@Name")%> '/>
</td>
<td>
<asp:textbox id= "txtquantity" runat= "server" text= ' <%# XPath ("@Quantity")%> ' width= '/>
</td>
<td>
<asp:radiobuttonlist id= "radiolist_isoriginal" runat= "server" Selectedvalue= ' <%# XPath ("@IsOriginal")%> '
repeatdirection= "Horizontal" >
<asp:listitem value= "True" > Original </asp:ListItem>
<asp:listitem value= "False" > Copy </asp:ListItem>
</asp:RadioButtonList>
</td>
<td>
<asp:textbox id= "txtcomment" runat= "server" text= ' <%# XPath ("Comment")%> '/>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</anthem:Repeater>
After this debugging, I think Ajax in addition to bring the interface to respond to the benefits of the rapid, because the introduction of a large number of JS, but also increased the difficulty of debugging, so the application of the time is still to be based on the circumstances of choice. Can't have Ajax on everything.