大家好!
问题如题,就是用一个HyperLink和一个DropDown来实现。
我知道我写的不对,但是不知道该怎么修改,呵呵,请大家帮忙看看。
具体功能:实现了当用户选择QQ时,会跳转到腾讯网站,如果选择SOHU,则会跳转到SOHU页面我的代码如下:
Default.aspx:
a hyperLink:
<asp:HyperLink ID="HyperLink1" runat="server" Font-Size="Large" Height="33px" Width="181px"
NavigateUrl="http://www.baidu.com">
HyperList
</asp:HyperLink><br />
a dropDownList:
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" OnTextChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="qq" />
<asp:ListItem Text="souhu" />
</asp:DropDownList>Default.aspx.cs:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.Text == "qq") //如果选择qq
{
HyperLink1.Text = "qq"; //文本为qq
HyperLink1.NavigateUrl = "http://www.qq.com"; //URL为qq.com
}
else //选择sohu
{
HyperLink1.Text = "sohu"; //文本为sohu
HyperLink1.NavigateUrl = "http://www.sohu.com"; //URL为sohu.com
} }
问题如题,就是用一个HyperLink和一个DropDown来实现。
我知道我写的不对,但是不知道该怎么修改,呵呵,请大家帮忙看看。
具体功能:实现了当用户选择QQ时,会跳转到腾讯网站,如果选择SOHU,则会跳转到SOHU页面我的代码如下:
Default.aspx:
a hyperLink:
<asp:HyperLink ID="HyperLink1" runat="server" Font-Size="Large" Height="33px" Width="181px"
NavigateUrl="http://www.baidu.com">
HyperList
</asp:HyperLink><br />
a dropDownList:
<asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" OnTextChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Text="qq" />
<asp:ListItem Text="souhu" />
</asp:DropDownList>Default.aspx.cs:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.Text == "qq") //如果选择qq
{
HyperLink1.Text = "qq"; //文本为qq
HyperLink1.NavigateUrl = "http://www.qq.com"; //URL为qq.com
}
else //选择sohu
{
HyperLink1.Text = "sohu"; //文本为sohu
HyperLink1.NavigateUrl = "http://www.sohu.com"; //URL为sohu.com
} }
解决方案 »
- 关于C#网页单选按钮
- 水晶报表第一页显示空行,急急急急急急急急急急!!!!
- 遍历CheckedListBox中的选中项
- 打包C#
- 关于往ACCESS中输入图片,急??????????????
- 在gdi+中如何绘制手动输入的字符串?
- 如何往excel文档中的某个单元格填值,以及在excel中画直线、图形甚至在单元格插入图片
- 谁知道怎么直接安装CAB到Smartphone模拟器上面,然后运行其中的程序?
- HttpWebRequest多线程并发,返回数据覆盖问题
- 高分请教 在C#程序中来实现SQL2000数据库和ACCESS2000数据库间的数据导入和导出
- 有没有办法获得windows的域验证?
- C# 动态生成带pivot table 的excel
{ Response.Redirect("http://www.qq.com");
}
else //选择sohu
{
Response.Redirect("http://www.sohu.com");
}