나는 ASP.NET C# 웹 사이트를 가지고 있으며 단추를 클릭하면 내 페이지의 HTML에서 내부 HTML을 검색하려고 시도하고 있습니다.runat = "server"특성이없는 경우 HTML 요소 찾기
내 문제 : 필자는 FindControl() 함수를 사용하지만 요소를 찾을 때 null을 반환합니다. 왜 이런 일이 생기고, 내가 뭘 잘못하고 있니?
내 HTML 페이지 :<%@ Page Title="test" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="test.aspx.cs" Inherits="test" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="ActualContent">
<div class="regMainContainer mainContainer container">
<!-- Attempting to get the below div -->
<!-- Knowtice it does not have runat="server",
I would prefer not to do that if I dont need to -->
<div id="courseDiv" class="courseContainer">
</div>
</div>
</asp:content>
버튼이 test.aspx.cs 파일 내부에 (클릭하면 실행
내 코드 :
HtmlGenericControl d = (HtmlGenericControl)FindControl("courseDiv");
이
감사합니다. Panel 방식의 예를 제공해 주시겠습니까? 그것은 ... ... 그럼 난 그냥 FindControl ("test"); –
이 질문에 대한 내 대답보기 : http://stackoverflow.com/questions/9611062/how-to-update-votes-client-side-using-webforms/9611282#9611282 – Evert