简体   繁体   English

打开URL并从代码隐藏处预填充ASPX页面中的文本框

[英]Open a URL and pre-fill a textbox in an ASPX page from code-behind

So what I'm doing is a little different than this: 所以我正在做的事情与此有些不同:

Access a control's property in an aspx page from another aspx page 从另一个aspx页面访问aspx页面中的控件属性

because what I'm trying to do is "push" a value forward to the next page rather than "pull" it from the previous page. 因为我要做的是将值“推”到下一页而不是从上一页“拉”出来。

What I need to do is open a new page from within an Intranet website application (actually, the page will have been previously used by the user) and pre-fill a textbox. 我需要做的是从Intranet网站应用程序中打开一个新页面(实际上,该页面之前已被用户使用过)并预填充了一个文本框。

Can this be done? 能做到吗? I'm currently forwarding to the new page using: 我目前正在使用以下方法转发到新页面:

String SUrl = "frmAuditSearch.aspx";
Server.Transfer(SUrl, true);

What I also need to do is fill a textbox called txtAuditID on frmAuditSearch.aspx with the AuditID from the current page I'm on. 我还需要做的是,使用我当前所在页面的AuditID填充frmAuditSearch.aspx上名为txtAuditID的文本框。

And yes, I know I can use something like: 是的,我知道我可以使用类似的方法:

String SUrl = "frmAuditSearch.aspx?AuditID = '" + MyAuditID + "'";
Server.Transfer(SUrl, true);

but I'm trying to avoid that because most of the time there's no AuditID and that'd require tinkering with too much code. 但是我试图避免这种情况,因为在大多数情况下,没有AuditID,并且需要修改太多的代码。

Sounds like you'd want to fill the text box with something like this. 听起来您想在文本框中填充这样的内容。

txtAuditID.Text = (Request["AuditID"] ?? String.Empty).ToString().

This allows the absence of the parameter if needed 如果需要,这允许不存在参数

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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