在asp.net中的dropdowncontrol中回发问题 [英] post back issue in dropdowncontrol in asp.net

查看:93
本文介绍了在asp.net中的dropdowncontrol中回发问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,



我在控制两个下拉控件时遇到问题,

问题:



Dear,

I am in trouble controlling two drop-down control,
Problem:

when,first drop-down control select,then 2nd drop-down control select(it has event),then first control reload,I have checked several way to find out the problem,I can not find any difficulties that will reload first drop-down

 if (!IsPostBack)
        {
           first & 2nd control load this way
        }





如果有人以前有过解决这个问题的经验,请帮助我。

NB:第一个控制rad下拉&第二个控件正常的asp.net drop -down.Page有Update Panel& Rad ajax Panel。



谢谢



if anyone have previous experience to solve this issue,please help me.
N.B.: first control rad dropdown & 2nd control normal asp.net drop-down.Page has Update Panel & Rad ajax Panel.

Thanks in

推荐答案

嗨!。



i认为你需要更新面板这个



首先你需要AJAX扩展VS2010有这个工具箱





首先将脚本管理器拖放到你的页面或你的母版页

所以可以使用ajax脚本

* note

脚本管理员只需一页

但是如果你有母版页你可以把它放在那里你不会再把它放了。



然后将更新面板拖放到您的页面

然后在更新面板下放置ContentTemplate

然后将您的下拉列表放入contenttemplate



代码将如下所示



Hi!.

i think you need updatepanel for this

first you need AJAX extensions VS2010 has this toolbox


first thing to do drag and drop script manager to you page or to your master page
so ajax script can be used
*note
script manager need just for one page
but if you have masterpage you can put it there so you would not put it again.

then drag and drop update panel to your page
then after that under update panel put ContentTemplate
then put your dropdownlist inside contenttemplate

the code will look like this

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:DropDownList ID="DDL1st" runat="server">
            </asp:DropDownList>
             <asp:DropDownList ID="DDL2nd" runat="server"  AutoPostBack="True">
            </asp:DropDownList>
        </ContentTemplate>







查看第二个DDL autopostback = true,以便第二个dll触发的任何事件都将被执行



记住所有这些都在更新面板内,所以所有回发都将被处理而不刷新你的页面。



i希望这是你问题的答案




Look at 2nd DDL the autopostback=true so that any event that fired by 2nd dll will be executed

remember all of this is inside the updatepanel so all post back will be handle without refreshing your page.

i hope this is the answer to your question


保持简单你会找到答案

第一次下拉

Well keep it simple you will find an answer
first dropdown
<drop....  önchange="dropdownchangeevent">
<listitem value="1">1</listitem>
<listitem value="2">2</listitem>
</drop....>



第二个


second one

<drop....>
<listitem value='1'>1</listitem>
<listitem value='2'>2</listitem>
</drop>



现在在c#


now in c#

protected void dropdownchangeevent(object sender, EventArgs e)
    {


//here from frist dropdown seleted values bind second dropdown

now add dropdown1.selecedvalue=whatever you want to select 

}





问候..:)



regards..:)


这篇关于在asp.net中的dropdowncontrol中回发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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