Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top