如何从ASP控件获取值并将其传递到另一页? [英] How to get the values from asp controls and pass it to another page?

查看:220
本文介绍了如何从ASP控件获取值并将其传递到另一页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

这是我的问题,我的网站上有一个职业页面,我希望用户能够使用一些过滤器来搜索工作,这些过滤器参数来自数据库,并且像这样被绑定

作业类型绑定到单选按钮列表中

部门绑定在列表框中

小时绑定在下拉列表中


我无法获得用户选择的值以将其传递到我的其他页面.

我尝试传递静态值以查看它是否有效并且确实起作用了

Hello Guys

Here is my problem I have a careers page in my website I want the user to be able to search for jobs using some filters the filters parameters is coming from database and they are binded like this

job type binded in radiobuttonlist

department binded in listbox

hours binded in dropdownlist


I cant get the values choosen by the user to pass it to my other page.

I tried to pass static values to see if it work and it did

<asp:ImageButton ID="ImageButton1" runat="server" Height="27px" ImageUrl="~/images/search-bt.png" Width="64px" CausesValidation="False" EnableViewState="False" onclick="ImageButton1_Click" PostBackUrl="~/Careers_Search_results.aspx?type=Pharmacist&hours=Full-Time&department=Sales %26 Marketing" />



任何人都可以帮助我随着用户选择它们而动态获得它们吗?

在此先感谢
:-)



can anyone please help me to get them dynamically as the user choose them?

thanks in advance
:-)

推荐答案

将值另存为会话变量,或将它们在查询字符串中传递到有问题的页面.
Save the values as session variables, or pass them in the querystring to the page in question.


一种方法是将值放入Session对象,然后从另一页读取这些值.您可以连接按钮的OnClick事件并执行类似的操作:

One way is to put the values into the Session object and then read those fro the other page. You can wire up the OnClick event of the button and do something like:

protected void ImageButton1_Click(object sender, EventArgs e)
{
    System.Web.HttpContext.Current.Session.Add("Key", "Value");
    Response.Redirect("~/Careers_Search_results.aspx");
}



然后,您可以使用以下方法在另一页的OnLoad事件中获取这些值:



You can then get these values in the OnLoad event of the other page with:

protected override void OnLoad(EventArgs e)
{
    if (!IsPostBack)
    {
        string data = System.Web.HttpContext.Current.Session["Key"].ToString();
    }
}



那应该会让您入门.



That should get you started.


这篇关于如何从ASP控件获取值并将其传递到另一页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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