在這條線Edit_English.Text = aEdit_English引發此錯誤;在下面的代碼中...System.NullReferenceException:對象不設置爲一個對象的一個實例。投擲錯誤
protected void btnEdit_Click(object sender, EventArgs e)
{
Button EditButton = (Button)EditLoginView.FindControl("EditButton");
Button SaveButton = (Button)EditLoginView.FindControl("SaveButton");
TitleLanguage.ActiveViewIndex = 2;
LanguageView.ActiveViewIndex = 2;
EditButton.Visible = false;
SaveButton.Visible = true;
TextBox Edit_English = (TextBox)ContentLoginView.FindControl("Edit_English");
TextBox Edit_French = (TextBox)ContentLoginView.FindControl("Edit_French");
TextBox Edit_FrenchT = (TextBox)TitleLoginView.FindControl("Edit_FrenchT");
TextBox Edit_EnglishT = (TextBox)TitleLoginView.FindControl("Edit_EnglishT");
Edit_English.Text = aEdit_English;
Edit_French.Text = aEdit_French;
Edit_EnglishT.Text = aEdit_EnglishT;
Edit_FrenchT.Text = aEdit_FrenchT;
}
這是頁面標記以及它。當我輸入visual studio時,訪問contentloginview沒有問題。
<asp:MultiView ID="LanguageView" runat="server">
<asp:View ID="English" runat="server"><asp:Label ID="en_content" runat="server"/></asp:View>
<asp:View ID="French" runat="server"><asp:Label ID="fr_content" runat="server"/></asp:View>
<asp:View ID="Edit" runat="server">
<asp:LoginView ID="ContentLoginView" runat="server">
<LoggedInTemplate>
<asp:TextBox ID="Edit_English" runat="server" TextMode="MultiLine" />
<asp:TextBox ID="Edit_French" runat="server" TextMode="MultiLine" />
</LoggedInTemplate>
</asp:LoginView>
</asp:View>
這是正確的......仍然有通過登錄視圖訪問那就麻煩了......也許是因爲它也是一個多視角?無論哪種方式,我找到了另一個工作。謝謝! – trowse