如何使用的Request.Form []在继承的网页表单 [英] how to use request.form[] in inherited web form

查看:136
本文介绍了如何使用的Request.Form []在继承的网页表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个母版页和一个网页表单从母版页继承,

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

标签在包含在

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

Web表单实施内容占位符。

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>

在后面的Web表单code,我想使用的Request.Form [tbAmount]来获得文本框的文本。

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

我知道在这种情况下使用TextBox.Text将是最简单的方法,但不要问我为什么,因为真的会需要几个小时来解释。

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.

让我们只说我创造aspx.cs的ASPX,而不是一个TextBox。

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

我该如何使用的Request.Form [tbAmount],以获取其文本后调回。

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

推荐答案

您将无法使用的Request.Form [tbAmount]直接,你将不得不使用文本框的客户端ID

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]

这是因为控制的asp.net ID及其corresponsing HTML控件的ID是不一样的,你必须使用ClientId属性来accesss它。

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.

这篇关于如何使用的Request.Form []在继承的网页表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆