回到同一页时如何保持下拉列表的选定值...? [英] how to maintain selected value of dropdownlist while come back to same page...?

查看:81
本文介绍了回到同一页时如何保持下拉列表的选定值...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的应用程序中,我使用了两个页面,

第一页中具有下拉列表项"和提交按钮"

如果我们单击此按钮,它将转到第二页

在第二页中,只有一个按钮,即取消按钮"

如果我们单击此按钮,它将返回首页.

我想要的是在第一页中,如果我们选择下拉列表项"中的任何一项,那么我们点击提交按钮,它将转到第二页.

在第二页中,如果我们单击取消按钮" ,它将返回上一页,并且仅使用"POSTBACKURL"来保持下拉列表中先前选择的值.


请指导我.

在此先感谢..

解决方案



尝试使用javascript的history.go-1函数,但它取决于浏览器
或其他选择是将该值存储在第一页的会话中
检查会话是否不为空
然后

ddl.selectedvalue = session["name"]
session["name"] = null
session.clear();


您至少要有2个选项:

1)如果单击``取消按钮''后不需要任何服务器端处理,则可以使用JavaScript并写入按钮的history.go(-1) onclick.这将带您到上一页,并且下拉列表将显示最后选择的值.

2)将下拉列表的选定值存储在Session Object中,并在第二页上经过服务器端处理后返回第一页时,对其进行分配.像这样的东西:

会话[" ] = ddlSomething.SelectedValue; 


在检索时,

 ddlSomething.SelectedValue =会话[" ];  

希望对您有帮助!


在这种情况下,请使用会话
会话[名称"] = dropdown.selectedValue;
在页面加载时检查会话值

Hi,

In my application i am using two pages,

In the first page having "Drop down list items" and "submit button"

if we click on this button it goes to second page

In the second page having only one button i.e "Cancel button"

if we click on this button it come back to first page.

What i want is in the first page,if we select any of the "drop down list item" then we click on submit button it''s goes to second page.

here in second page if we click on "Cancel button" it come back to previous page and maintain the whatever the previous selected value in the drop down list using only "POSTBACKURL".


Please guide me..

Thanks in advance..

解决方案

hi,

try history.go-1 funtion of javascript but it browser dependent
or other option is store that value in session in the first Page
check session if it not null
then

ddl.selectedvalue = session["name"]
session["name"] = null
session.clear();


You have (minimum) 2 options:

1) If you do not need any server side processing after clicking ''Cancel Button'', you can use JavaScript and write history.go(-1) onclick of the button. That will take you to the previous page and drop-down-list will show the last selected value.

2) Store the selected value of the drop-down-list in a Session Object and assign the same when you come back to the 1st page after some server side processing on 2nd page. Something like:

Session["DropDownSelVal"] = ddlSomething.SelectedValue;


And on retrival,

ddlSomething.SelectedValue = Session["DropDownSelVal"];



Hope this helps!


for such scenario,use session
Session["name"]=dropdown.selectedValue;
on page load check the session value


这篇关于回到同一页时如何保持下拉列表的选定值...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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