变量值未在updatepanel中更新 [英] Variable value not being updated in updatepanel

查看:56
本文介绍了变量值未在updatepanel中更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个更新面板,其中的下拉菜单设置为true true.
根据下拉菜单中的选择,将更新变量值,该变量值将在链接中用于填充查询字符串值.

但是,如果使用更新"面板,则不会更新变量值,而是保留加载期间获得的旧值.

我该如何实现?
谢谢.

I have an update panel where I have a dropdown set to autopostback true.
Depending on the selection in the dropdown, a variable value is updated which is used in a link to populate a query string value.

But if I use the update panel, the variable value is not being updated, keeping the old value that it gets during load.

How can I achieve this?
Thanks.

推荐答案

试试这个

ASP.NET AJAX:更新面板中的下拉列表未更新 [
Try this

ASP.NET AJAX:dropdownlist inside a update panel is not updating[^]

BTW why don''t you include your code in your question for quick response?
Let us know.


在UpdatePanel中放置一个隐藏字段.下拉值更改时,用所需的值更新隐藏的字段(服务器控件).

现在,使用此隐藏字段值填充查询字符串.完成!
Put a hidden field in UpdatePanel. On dropdown value change, update the hidden field(server control) with the desired value.

Now, use this hidden field value to populate query string. Done!



如果您在类级别声明变量.
例如.

公共局部类_Default:System.Web.UI.Page
{
public int Count = 0;


受保护的void button1_Click(对象发送者,EventArgs e)
{
计数= 5;
}

受保护的void button2_Click(对象发送者,EventArgs e)
{
response.write(count);
}

}

输出为:0


因此,将变量声明为静态变量.


公共局部类_Default:System.Web.UI.Page
{
public static int Count = 0;


受保护的void button1_Click(对象发送者,EventArgs e)
{
计数= 5;
}

受保护的void button2_Click(对象发送者,EventArgs e)
{
response.write(count);
}

}

输出是:5

我认为它可以解决您的问题.
Hi,
If your declare the variable in class level.
eg.

public partial class _Default : System.Web.UI.Page
{
public int Count = 0;


protected void button1_Click(object sender, EventArgs e)
{
count = 5;
}

protected void button2_Click(object sender, EventArgs e)
{
response.write(count);
}

}

output is : 0


So dclare the variable as static.


public partial class _Default : System.Web.UI.Page
{
public static int Count = 0;


protected void button1_Click(object sender, EventArgs e)
{
count = 5;
}

protected void button2_Click(object sender, EventArgs e)
{
response.write(count);
}

}

output is : 5

i think it solve ur problem.


这篇关于变量值未在updatepanel中更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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