开发者

Find control from html to c# in asp.net [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 10 years ago. 开发者_如何学编程

I have problem that how to get html control id in c# code behind page.?? thanks in advance......


If your control is declared in the markup (like <asp:Label ID="myLabel" runat="server"/>) you can just use autogenerated myLabel property in code behind. Otherwise, if the control is created dynamically or declared in a template (for example within Repeater) you need to know its parent container and do container.FindControl("controlID").


If You have input html control and wish to access its value You can get this on lage load using Page.Request.Params property:

http://msdn.microsoft.com/en-us/library/system.web.httprequest.params.aspx

Or if You wish to access it fully (for read/write) You have to add runat=server attribute and then (for asp.net 3.5)

http://www.w3schools.com/aspnet/aspnet_refhtmlcontrols.asp

Here You go: aspx:

<form id="form1" runat="server">
<div>
    <input type="text" runat="server" id="htmlText" name="htmlText"/>
    <asp:Button ID="Button1" runat="server" Text="Button" />
</div>
</form>

cs:

...
        protected void Page_Load(object sender, EventArgs e) {
            htmlText.Value = "kuku";
        }
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜