如何在代码隐藏的下拉列表上调用BalloonPopupExtender上的SelectedIndexChanged事件 [英] How to call BalloonPopupExtender on dropdown SelectedIndexChanged event on code behind

查看:100
本文介绍了如何在代码隐藏的下拉列表上调用BalloonPopupExtender上的SelectedIndexChanged事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

如何在下拉列表上调用BalloonPopupExtender在

i后面的代码上的SelectedIndexChanged事件有一个示例代码请看看那个,


< asp:DropDownList runat = server ID = ddlPollutant 宽度 = 130px AutoPostBack = true OnSelectedI ndexChanged = ddlPollutant_SelectedIndexChanged >

< asp:ListItem 文字 = - - 选择 - = - 1 已选择 = True > < / asp:ListItem >
< asp:ListIte m 文字 = H2S = 34.08 > < / asp:ListItem >
< asp:ListItem 文本 = SO2 = 64.0628 > < / asp:ListItem >
< asp:ListItem 文本 = HCl = 36.461 > < / asp:ListItem >
< asp:ListItem 文本 = NH3 = 17.0306 > < / asp:ListItem >
< asp:ListItem Text = HCN = 27.0253 > < / asp:ListItem >
< / asp:DropDownList < span class =code-keyword>>

< asp:Panel runat = server ID = Panel1 样式 = display:none >
< table cellpadding = 0 cellspacing = 0 border = 0 >
< tr >
< td nowrap = nowrap >
低pH下的NaOH
< / td >
< / tr >
< tr >
< td nowrap = nowrap >
高pH下的NaOH
< / td >
< / tr >
< / table >
< / asp:Panel >

protected void ddlPollutant_SelectedIndexChanged(object sender,EventArgs e)
{
if(ddlPollutant) .SelectedItem.Text ==H2S)
{
BalloonPopupExtend er BPE = new BalloonPopupExtender();
BPE.TargetControlID = ddlPollutant.ID;
BPE.BalloonPopupControlID = Panel1.ID;
BPE.Position = BalloonPopupPosition.BottomRight;
BPE.BalloonStyle = BalloonPopupStyle.Rectangle;
BPE.BalloonSize = BalloonPopupSize.Medium;
BPE.UseShadow = true;
BPE.DisplayOnMouseOver = true;
BPE.DisplayOnClick = false;
BPE.DisplayOnFocus = false;
Panel1.Attributes.Add(style,display:block);
}
if(ddlPollutant.SelectedItem.Text ==SO2)
{
Panel1.Attributes.Add(style,display:none);
}
if(ddlPollutant.SelectedItem.Text ==HCl)
{
Panel1.Attributes.Add(style,display:none);
}
if(ddlPollutant.SelectedItem.Text ==NH3)
{
Panel1.Attributes.Add(style,display:none);
}
if(ddlPollutant.SelectedItem.Text ==HCN)
{
Panel1.Attributes.Add(style,display:none);
}
}

但它不适合我。

请给出解决方案。







感谢ADvance,

VenkiDesai。

解决方案

我不知道BalloonPopupExtender,但我使用的是DropDownList.ToolTip,效果很好。

Hi All,

How to call BalloonPopupExtender on dropdown SelectedIndexChanged event on code behind

i have a sample code please have a look on that,


<asp:DropDownList runat="server" ID="ddlPollutant" Width="130px" AutoPostBack="true" OnSelectedIndexChanged="ddlPollutant_SelectedIndexChanged">

         <asp:ListItem Text="--Select--" Value="-1" Selected="True"></asp:ListItem>
         <asp:ListItem Text="H2S" Value="34.08"></asp:ListItem>
         <asp:ListItem Text="SO2" Value="64.0628"></asp:ListItem>
         <asp:ListItem Text="HCl" Value="36.461"></asp:ListItem>
         <asp:ListItem Text="NH3" Value="17.0306"></asp:ListItem>
         <asp:ListItem Text="HCN" Value="27.0253"></asp:ListItem>
         </asp:DropDownList>

<asp:Panel runat="server" ID="Panel1" Style="display: none">
    <table cellpadding="0" cellspacing="0" border="0">
    <tr>
      <td nowrap="nowrap">
      NaOH at low pH
      </td>
    </tr>
    <tr>
      <td nowrap="nowrap">
     NaOH at high pH
      </td>
    </tr>
    </table>
 </asp:Panel>

protected void ddlPollutant_SelectedIndexChanged(object sender, EventArgs e)
    {
    if (ddlPollutant.SelectedItem.Text == "H2S")
    {
    BalloonPopupExtender BPE = new BalloonPopupExtender();
    BPE.TargetControlID = ddlPollutant.ID;
    BPE.BalloonPopupControlID = Panel1.ID;
    BPE.Position = BalloonPopupPosition.BottomRight;
    BPE.BalloonStyle = BalloonPopupStyle.Rectangle;
    BPE.BalloonSize = BalloonPopupSize.Medium;
    BPE.UseShadow = true;
    BPE.DisplayOnMouseOver = true;
    BPE.DisplayOnClick = false;
    BPE.DisplayOnFocus = false;
    Panel1.Attributes.Add("style", "display:block");
    }
    if (ddlPollutant.SelectedItem.Text == "SO2")
    {
    Panel1.Attributes.Add("style", "display:none");
    }
    if (ddlPollutant.SelectedItem.Text == "HCl")
    {
    Panel1.Attributes.Add("style", "display:none");
    }
    if (ddlPollutant.SelectedItem.Text == "NH3")
    {
    Panel1.Attributes.Add("style", "display:none");
    }
    if (ddlPollutant.SelectedItem.Text == "HCN")
    {
   Panel1.Attributes.Add("style", "display:none");
    }
    }

But it was not working for me .

Please give solution to this.




Thanks in ADvance,
VenkiDesai.

解决方案

I don't know about the BalloonPopupExtender, but I use the DropDownList.ToolTip and that works great.


这篇关于如何在代码隐藏的下拉列表上调用BalloonPopupExtender上的SelectedIndexChanged事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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