다음 코드를 사용하고 있습니다.FindControl을 사용할 때 개체 참조가 개체의 인스턴스로 설정되지 않았습니다.
의 .ascx 파일 : 뒤에
<div class="DemoArea">
<asp:Button ID="btnCaseComplete" runat="server" Text="Case Complete" CssClass="btn_contentlist"
onclick="btnCaseComplete_Click" OnClientClick="scroll(0,0);$.loading({mask: true, effect: 'ellipsis update'});"/>
<ComponentArt:Dialog ID="caDropDownDialog" runat="server" Modal="true" Alignment="MiddleCentre" AllowDrag="true" AllowResize="false" AnimationDuration="1000"
CloseTransition="Fade" RenderOverWindowedObjects="true" ShowTransition="Fade" AnimationType="Outline" CssClass="ModalMask">
<Header><p class="header">Case Complete</p></Header>
<Content>
<asp:Panel ID="panSelectArea" runat="server" CssClass="modalMaskContent">
<p><span class="red">Please Note:</span>Once you click
<span class="bold">Ok</span>, your
case will be Submitted to ACR and you will not be able to edit the Case again.
<span class="style2">To continue editing the case, click </span>
<span class="bold">Cancel</span>. You will be taken back
to the Case Wizard and your case will not be submitted to ACR.</p>
</asp:Panel>
</Content>
<Footer>
<center class="modalMaskFooter">
<asp:Button ID="btnOK" runat="server" CausesValidation="false"
CssClass="btn_contentlist" OnClientClick="caDropDownDialog.IsShowing=false" Text="OK" />
<asp:Button ID="btnCancel" runat="server" CausesValidation="false"
CssClass="btn_contentlist" OnClientClick="caDropDownDialog.Close();" Text="Cancel" />
</center>
</Footer>
</ComponentArt:Dialog>
</div>
코드 :
CaseContentList obj = new CaseContentList(); // creating the object of case content list control to this page
LinkButton lbtn = (LinkButton)((DataList)obj.FindControl("dlstContentList")).FindControl("lbtnDisplay");
if (lbtn.Text == "Final Page")
{
caDropDownDialog.IsShowing = true;
}
else
Page.ClientScript.RegisterStartupScript(this.GetType(), "Window", "alert('Add Final Page First.');", true);
그러나 그것은 오류를주고 '개체 참조가 개체의 인스턴스로 설정되지 않았습니다'.
이것은 당신이 중 하나를 잘못 캐스팅하거나 올바른 개체를 참조하지 않는 것을 의미합니다, 귀하의 영문 코드 –
를 붙여주십시오 나는 당신'의 FindControl 한 생각 '명령문이 실패합니다. 설립 된 컨트롤을 사용하기 전에 null 검사를 추가하십시오. –
어떤 코드에서이 코드를 호출합니까? – TcKs