c# - I get a "Microsoft JScript runtime error: Object doesn't support this property or method" error for anything with autopostback=true on one of my pages -


i have .net application following aspx code:

<%@ page language="c#" autoeventwireup="true" codebehind="default.aspx.cs" inherits="webapplication1.default"%> <%@ register tagprefix="asp" namespace="ajaxcontroltoolkit" assembly="ajaxcontroltoolkit"%> <%@ register assembly="telerik.web.ui" namespace="telerik.web.ui" tagprefix="telerik"%>  <!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">  <html xmlns="http://www.w3.org/1999/xhtml" >  <body> <form id="form1" runat="server">  <asp:toolkitscriptmanager id="scriptmanager1" runat="server" enablepartialrendering="true"> </asp:toolkitscriptmanager> <table> <tr> <td>     <asp:radiobuttonlist id="rbltest" runat="server" autopostback="true"          onselectedindexchanged="rbltest_selectedindexchanged">         <asp:listitem text="1" value="1"></asp:listitem>         <asp:listitem text="2" value="2"></asp:listitem>     </asp:radiobuttonlist> </td> <td>     <asp:placeholder id="ph1" runat="server" visible="false">         text     </asp:placeholder> </td> </tr> </table> </form> </body> </html> 

i have c# method follows:

protected void rbltest_selectedindexchanged(object sender, eventargs e) {     if (rbltest.selectedvalue == "2")         ph1.visible = true;     else         ph1.visible = false; } 

below crash occurred. crashes time use control has autopostback=true. use same syntax on 15 other forms , work fine. missing property somewhere or there wrong method? had updatepanel around controls , plan on adding again, need postback working first.

<script type="text/javascript"> //<![cdata[ var theform = document.forms['default']; if (!theform) {     theform = document.default; } function __dopostback(eventtarget, eventargument) {     if (!theform.onsubmit || (theform.onsubmit() != false)) {         theform.__eventtarget.value = eventtarget;         theform.__eventargument.value = eventargument;         theform.submit();             <-----crashed @ line.     } } //]]> </script> 

what missing or there common mistake may have made somewhere? in advance help.

your __dopostback script trying submit form id "default" (see document.forms["default"] line; yet markup shows form id "form1" it's clear why doesn't work: __dopostback function not finding form , calling theform.submit() fails.

you can attempt fix renaming form use id "default" since don't think can control way __dopostback script generated.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -