简体   繁体   中英

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

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM