c# - 基于查询字符串的行为

标签 c# asp.net

我有两个页面:Default.aspx 和 Target.aspx。在 Default.aspx 上有两个按钮:

Button1 重定向到 ("~/Target.aspx?mode=\"drop\"");
Button2 重定向到 ("~/Target.aspx?mode=\"textbox\"");

On Target.aspx 后面的代码如下:

string display = Request.QueryString["mode"];
    switch (display)
    {
        case "textbox":
            TextBox1.Visible = true;
            DropDownList1.Visible = false;
            break;
        case "drop":
            TextBox1.Visible = false;
            DropDownList1.Visible = true;
            break;

    }

如您所见,对于 Button1,Target.aspx 应该隐藏 TextBox1 并显示 DropDownList1。然而,这是行不通的。你能帮助我吗 ?谢谢

最佳答案

重定向到 ("~/Target.aspx?mode=drop"); 在重定向 URL 中删除不带引号的文本框

关于c# - 基于查询字符串的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8868967/

相关文章:

c# - 与 Throws<T> 方法类似的通用 DoesNotThrow<T> 方法在哪里?

c# - 将原始数据发送到 Zebra TTP 2030 打印机并获取其状态

c# - 如何在 ASP.NET 中将对象保存到 session 并在 View 中访问它

c# - 使用 HttpContext.Current.Application 存储简单数据

c# - ASP.NET MVC : Ugly code needs refactoring (returning three values)

c# - 如何使用 GetManifestResourceStream() 方法检索 JPG 图像?

javascript - 使用 CheckBox 启用 CheckBoxList? - ASP.NET

c# - 在render事件中获取某个div的html代码

c# - PDB 文件在第二次编译时变大,然后保持相同大小

c# - 我从只返回 Task 而不是 Task<T> 的方法返回什么?