我已經使用多視圖選項創建了兩個視圖。現在運行期間,我得到這個錯誤:視圖在運行時不會創建
Microsoft JScript runtime error: 'null' is null or not an object
爲這個代碼:
window.onload = function checkbox(check) {
var check = document.getElementById("<%=cbxAuth.ClientID %>"); //<- error from here
check.onchange = function checkbox(check) {
if (this.checked == true)
{
document.getElementById("<%=txtUsName.ClientID %>").disabled = false;
document.getElementById("<%=txtPassword.ClientID %>").disabled = false;
}
else
{
document.getElementById("<%=txtUsName.ClientID %>").disabled = true;
document.getElementById("<%=txtPassword.ClientID %>").disabled = true;
}
}; // Till here
};
現在,當我分析了動態代碼,我意識到這是我的第二個觀點並且整個代碼不存在於動態運行時。
這是我創建視圖前端代碼:
<td>
<asp:Button Text="Generate License" BorderStyle="None" ID="Tab1" CssClass="Initial"
runat="server" OnClick="Tab1_Click" ValidationGroup="generatelicence" />
<asp:Button Text="Mail Configuration" BorderStyle="None" ID="Tab2" CssClass="Initial"
runat="server" OnClick="Tab2_Click" ValidationGroup="sendemail" />
<asp:MultiView ID="MainView" runat="server">
這是代碼,而我創造了第二種觀點:
<asp:View ID="View2" runat="server">
<table style="width: 100%; border-width: 1px; border-color: #666; border-style: solid">
<tr>
<td class="style15">
FROM
</td>
<td>
<asp:TextBox ID="txtFrom" runat="server" Width="414px" CssClass="Textbox1"></asp:TextBox>
<asp:LinkButton ID="lbEdit0" runat="server" onclick="lbEdit0_Click"> Edit </asp:LinkButton>
<asp:RegularExpressionValidator ID="regexSendFrom" runat="server" ControlToValidate="txtFrom"
ErrorMessage="Enter a Valid Name" ValidationExpression="\w+([\s-_]\w+)*" ValidationGroup="sendemail"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style15">
SENDER MAIL</td>
<td>
<asp:TextBox ID="txtMailAdd" runat="server" Width="414px" CssClass="Textbox1"></asp:TextBox>
<asp:LinkButton ID="lbEdit1" runat="server" onclick="lbEdit1_Click"> Edit
</asp:LinkButton>
<asp:RegularExpressionValidator ID="regexSender" runat="server"
ControlToValidate="txtMailAdd" ErrorMessage="Incorrect Mailing Address"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="sendemail"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style15">
SMTP IP
</td>
<td>
<asp:TextBox ID="txtSMTP" runat="server" Width="414px" CssClass="Textbox1"></asp:TextBox>
<asp:LinkButton ID="lbEdit2" runat="server" onclick="lbEdit2_Click"> Edit
</asp:LinkButton>
<asp:RegularExpressionValidator ID="regexSMTP" runat="server"
ControlToValidate="txtSMTP" ErrorMessage="IP Address is Incorrect"
ValidationExpression="(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)"
ValidationGroup="sendemail"></asp:RegularExpressionValidator>
</td>
</tr>
<tr>
<td class="style15">
SMTP AUTHENTICATION
</td>
<td>
<asp:CheckBox ID="cbxAuth" runat="server" />
</td>
</tr>
<tr>
<td class="style16">
</td>
<td class="style11">
User Name
<asp:TextBox ID="txtUsName" runat="server" Enabled="false" Width="299px" CssClass="Textbox1"></asp:TextBox>
<asp:LinkButton ID="lbEdit3" runat="server" OnClick="lbEdit3_Click"> Edit
</asp:LinkButton>
<br />
Password
<asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="300px" Enabled="false"
CssClass="Textbox1"></asp:TextBox>
<asp:LinkButton ID="lbEdit4" runat="server" OnClick="lbEdit4_Click"> Edit
</asp:LinkButton>
<asp:RequiredFieldValidator ID="reqPass" runat="server" ControlToValidate="txtPassword"
Display="Dynamic" ErrorMessage="Enter a Password" ValidationGroup="sendemail"></asp:RequiredFieldValidator>
<asp:RequiredFieldValidator ID="reqUserMail" runat="server" ControlToValidate="txtUsName"
Display="Dynamic" ErrorMessage="Enter a User Name" ValidationGroup="sendemail"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style15"> RECEIVER </td>
<td> <asp:TextBox ID="txtReceiver" runat="server" CssClass="Textbox1" Width="414px"></asp:TextBox>
<asp:LinkButton ID="lbEdit5" runat="server" OnClick="lbEdit5_Click"> Edit </asp:LinkButton>
</td>
</tr>
<tr>
<td class="style15">
TO MAIL
</td>
<td>
<asp:TextBox ID="txtTo" runat="server" CssClass="Textbox1" Width="414px"></asp:TextBox>
<asp:LinkButton ID="lbEdit6" runat="server" OnClick="lbEdit6_Click"> Edit
</asp:LinkButton>
<asp:RegularExpressionValidator ID="regexTo" runat="server"
ControlToValidate="txtTo" Display="Dynamic" ErrorMessage="Enter an E-Mail Address"
ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
<asp:RequiredFieldValidator ID="reqMailTo" runat="server"
ControlToValidate="txtTo" ErrorMessage="Enter a Mailing Address"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td class="style15">
SUBJECT
</td>
<td class="style11">
<asp:TextBox ID="txtSub" runat="server" Width="414px" CssClass="Textbox1"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style15">
CONTENT
</td>
<td>
<asp:TextBox ID="txtBody" runat="server" Width="414px" CssClass="Textbox1" Columns="10"
Rows="10" TextMode="MultiLine"></asp:TextBox>
</td>
</tr>
<tr>
<td class="style16">
ATTACHMENT
</td>
<td>
<asp:FileUpload ID="fupAttach" runat="server" CssClass="Textbox1"
Width="414px" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
<tr>
<td colspan="2">
<tr>
<td colspan="2" style="margin-left: 40px" align="center">
<asp:Label ID="lblMailFail" runat="server" ForeColor="Red"></asp:Label>
</td>
</tr>
</td>
</tr>
<tr>
<td colspan="2" align="center" class="style12" style="margin-left: 500px">
<asp:Button ID="btnSMail" runat="server" CssClass="btn" Text="Send"
onclick="btnSMail_Click" />
<asp:Button ID="btnCancelMail" runat="server" CssClass="btn" Text="Cancel" />
</td>
</tr>
<tr>
<td colspan="2">
</td>
</tr>
</table>
</asp:View>
什麼正當理由,爲什麼會這樣?
這可以幫助你[微軟JScript運行時錯誤(http://stackoverflow.com/questions/2914033/microsoft-jscript-runtime-error-null-is-null-or-not-an-object ) –