how to use request.form[] in inherited web form

早过忘川 提交于 2019-12-13 03:44:29

问题


I have a Master page and one web form inherited from that master page,

the tag is in master page which contains a content place holder inside

Master Page:
    <form runat="server">
        <asp:ContentPlaceHolder ID="MainContent" runat="server" />
    </form>

the web form implement that content place holder.

WebForm.aspx:
    <asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
        <asp:TextBox ID="tbAmount" runat="server" />
    </asp:content>

in the code behind web form, I wanna use Request.Form["tbAmount"] to get Text of TextBox.

I know in this case using TextBox.Text will be the easiest way, but dont ask me why, cuz it will take hours to explain.

let's just say I create a TextBox in aspx.cs instead of aspx.

how can I use Request.Form["tbAmount"] to get its Text after it posted back.


回答1:


You will not be able to use Request.Form["tbAmount"] directly, you will have to use the clientid of the textbox

Request.Form[tbAmount.ClientId]

This is because asp.net ID of a control and its corresponsing HTML control's id are not the same, you have to use the ClientId property to accesss it.



来源:https://stackoverflow.com/questions/13466646/how-to-use-request-form-in-inherited-web-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!