DropDownList重定向没有发生。 [英] DropDownList Redirect is not happening.
本文介绍了DropDownList重定向没有发生。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello All,
我尝试使用以下代码重定向所选值,但它对我不起作用..
我们非常感谢任何建议。
受保护 void DropDownList1_SelectedIndexChanged( object sender,EventArgs e)
{
if (DropDownList1.SelectedValue == Exclusive Content)
{
Response.Redirect( http://professionaldirect.microsoft。 com)
}
else if (DropDownList1.SelectedValue == PDM Availibility)
{
Response.Redirect( https://expert.partners.extranet.microsoft.com/userprofile/)
}
else if (DropDownList1.SelectedValue == Windows Azure帮助)
{
Response.Redirect( < span class =code-string> http://www.windowsazure.com/en-us/manage/windows/)
}
}
问候,
Srinath Patil
解决方案
在DropDownList aspx代码中添加AutoPostBack =true
。喜欢这个..
< asp:dropdownlist id = DropDownList1 runat = server onselectedindexchanged = DropDownList1_SelectedIndexChanged autopostback = true xmlns:asp = #unknown >
< asp:listitem text = -----选择----- value = 0 > < / asp:listitem >
< / asp:dropdownlist >
- 更新后的答案
您的比较错误。对于下面的下拉值
DropDownList1.SelectedText将是独家内容
而
DropDownList1.SelectedValue将是http://professionaldirect.microsoft.com
< asp:ListItem 文本 < span class =code-keyword> = 独家内容 值 = http://professionaldirect.microsoft.com >
尝试更改此
if (DropDownList1.SelectedText == 独家内容)
{
Response.Redirect ( http://professionaldirect.microsoft.com?Value= + DropDownList1.SelectedText)
}
在你的ASP.NET文件中(.aspx文件) ,将AutoPostBack =true
添加到下拉列表的ASP.NET标记中。
希望这个帮助
Hello All,
I have tried to redirect a selected value using the below code and it does not work for me..
Any suggestions are highly appreciated.
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if(DropDownList1.SelectedValue=="Exclusive Content")
{
Response.Redirect("http://professionaldirect.microsoft.com")
}
else if(DropDownList1.SelectedValue=="PDM Availibility")
{
Response.Redirect("https://expert.partners.extranet.microsoft.com/userprofile/")
}
else if(DropDownList1.SelectedValue=="Windows Azure Help")
{
Response.Redirect("http://www.windowsazure.com/en-us/manage/windows/")
}
}
Regards,
Srinath Patil
解决方案
AddAutoPostBack="true"
in your DropDownList aspx code. Like this ..
<asp:dropdownlist id="DropDownList1" runat="server" onselectedindexchanged="DropDownList1_SelectedIndexChanged" autopostback="true" xmlns:asp="#unknown"> <asp:listitem text="-----Select-----" value="0"></asp:listitem> </asp:dropdownlist>
-- Updated Answer
Your camparison is wrong. For the below dropdown value
DropDownList1.SelectedText would be "Exclusive Content"
whereas
DropDownList1.SelectedValue would be "http://professionaldirect.microsoft.com"
<asp:ListItem Text="Exclusive Content" Value="http://professionaldirect.microsoft.com">
Try changing this
if(DropDownList1.SelectedText=="Exclusive Content") { Response.Redirect("http://professionaldirect.microsoft.com?Value="+DropDownList1.SelectedText) }
Hi,
In your ASP.NET file (.aspx file), addAutoPostBack="true"
to the ASP.NET tag of your drop down list.
Hope this helps.
这篇关于DropDownList重定向没有发生。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文