如何获取按钮以外的页面上按钮的文本值 [英] How to fetch the text value of button on the page other than the button is

查看:60
本文介绍了如何获取按钮以外的页面上按钮的文本值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个页面上有一个按钮。我想在我重定向的下一页上访问该按钮的文本值。要访问我写过以下代码的文本框的值

Request.Form [txtnme]。tostring() ;

我应该为按钮写什么?

I have one button on one page. I want to access the text value of that button on the next page where I am redirecting.To access values of text boxes I have written following code
Request.Form["txtnme"].tostring();
What should I write for button?

推荐答案

我创建了一个示例ASP.NET Web Form应用程序。以下是我采取的步骤:



1.在Default.aspx中,修改MainContent放置器,如下所示:



I have created a sample ASP.NET Web Form application. Followings are the steps I have taken:

1. In Default.aspx, modify the "MainContent" placehoder like following:

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <asp:Button ID="btnSample" runat="server" Text="Button Text Value"  PostBackUrl="~/About.aspx" />
    <asp:TextBox ID="TxtbtnSample" ClientIDMode="Static" runat="server" Text="Some Text Value"></asp:TextBox>
</asp:Content>







2.你需要专注于正确应用程序生成的控件的键。右键单击浏览器中的页面,使用Default.aspx页面(或上一页)的ViewSource。您将能够看到以下内容:






2. You need to focus on correct key for the control generated by application. Use ViewSource of the Default.aspx page(or your previous page) by right clicking on the page in the browser. You will be able to see something like:

<section class="content-wrapper main-content clear-fix">

   <input type="submit" name="ctl00


MainContent
MainContent


btnSample value = 按钮文本值 onclick = javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(& quot; ctl00
btnSample" value="Button Text Value" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00


这篇关于如何获取按钮以外的页面上按钮的文本值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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