DropdownBox选择项转到NaviGated Url [英] DropdownBox Selted item To NaviGated Url

查看:92
本文介绍了DropdownBox选择项转到NaviGated Url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在设计一个应用程序.要采取一个下拉框,按钮.然后选择项目,然后按按钮转到该页面.我正在尝试但出现错误执行子请求",所以请给个想法以解决此问题.

Hi,
I am Design One Application. To Taken One Drop Down Box, button. Then Selected Item Then Press Button Go to That Page. I am Trying But Error " Execute Child Request " So please Give For Idea To Solve This Problem.

推荐答案

像这样尝试

在Aspx页面中:


try like this

In Aspx Page:


<div>
        <asp:DropDownList ID="DropDownList1" runat="server" Height="16px" Width="66px">
            <asp:ListItem>select</asp:ListItem>
            <asp:ListItem>http://www.codeproject.com/Questions/383971/DropdownBox-Selted-item-To-NaviGated-Url</asp:ListItem>
            <asp:ListItem>http://www.google.co.in/</asp:ListItem>


        </asp:DropDownList>


        <br />
        <br />
        <br />
        <asp:Button ID="Button3" runat="server" Text="Button" />


    </div>




在CS页面中:




In CS Page:

Protected Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        Response.Redirect(DropDownList1.SelectedItem.Text)
    End Sub


朋友,

试试下面的代码...
这将解决您的问题...


Hi friend,

Try this below code...
this will solve ur probelm...


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DropDownList runat="server" ID="DDl">
            <asp:ListItem>One</asp:ListItem>
            <asp:ListItem>Two</asp:ListItem>
            <asp:ListItem>Three</asp:ListItem>
        </asp:DropDownList>
        <br />
        <asp:Button  runat="server" ID="btnSubmit" Text="Submit"

            onclick="btnSubmit_Click"/>
    </div>
    </form>
</body>
</html>






在U背后的代码中编写此代码...







In Code Behind U Write this Code...


protected void btnSubmit_Click(object sender, EventArgs e)
   {
       if (DDl.SelectedIndex == 0)
       {
           Response.Redirect("One.aspx");
       }
       else if (DDl.SelectedIndex == 1)
       {
           Response.Redirect("Two.aspx");
       }
       else if (DDl.SelectedIndex == 2)
       {
           Response.Redirect("Three.aspx");
       }
   }


这篇关于DropdownBox选择项转到NaviGated Url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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