直接到下载页面后清除文本框 [英] clear the textbox after direct to a download page

查看:56
本文介绍了直接到下载页面后清除文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2页。 main.aspx和download.aspx

page_load at download.aspx是下载一个文件

文本框和下载按钮在main.aspx,按钮重定向到download.aspx
现在,这是


问题是,我按下下载按钮后如何清除文本框?



我试过:

1. this.Textbox1.Text =;重定向之前和之后。

2. ScriptManager.RegisterStartupScript(this,this.GetType(),alert,document.getElementById(''Textbox1'')。value ='''' ,是的;);重定向之前和之后

3.在Response.Redirect(download.aspx)之后重定向到main.aspx;



没有上面的方法是有效的,我还能尝试什么?有什么问题?为什么文本框不能设置为空?

i have 2 pages. main.aspx and download.aspx
page_load at download.aspx is to download a file
textbox and download button at main.aspx, button redirect to download.aspx

after i filled the textbox and press the button, the page remain at main.aspx and file is downloaded from download.aspx.
now the problem is, how can i clear the textbox after i press the download button?

I tried:
1. this.Textbox1.Text = ""; before and after the redirect.
2. ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "document.getElementById(''Textbox1'').value =''''", true); before and after the redirect
3. redirect to main.aspx after Response.Redirect("download.aspx");

none of the method above is working, what else can i try? and what is the problem? why the textbox cannot set to blank?

推荐答案

如果您的文本框正在页面加载事件中填充,您可以检查page.ispostback以确定是否清除它或不?
If your textbox is being populated in the page load event, you could check for page.ispostback to determine whether to clear it or not?


参考下面的文章



为什么文本框在回发期间保持数据,即使View State设置为关闭



了解页面状态和文本框,并尝试相应地实现。
Refer to the below article

Why textbox persists data during postback even if View State set to off

Understand the states of the page and the textbox and try to implement accordingly.


这篇关于直接到下载页面后清除文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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