weixin_33698043 2009-05-18 04:00 采纳率: 0%
浏览 26

链接到选项下拉菜单

Can you link to a specific value in an options drop down box from another page?

In other words, let's say that I'm on page 1 and I want to anchor link to page 2 that has an options drop down box with 3 different values in it. Let's say by default when you go to page 2, the drop down option box is showing value 1.

Is it possible to link to page 2 and change the value of that option box on the fly? Whereas when you click the link on page 1 it will automatically show value 3 instead of 1 on page 2.

  • 写回答

2条回答 默认 最新

  • 斗士狗 2009-05-18 04:07
    关注

    This is certainly possible. You can pass a flag in your querystring. So, on page1 you have a link to page2 like "page2.aspx?option=3". Then, in page2's PageLoad method, simply read that value from the querystring (Request.QueryString["option"]) and set the selected item of the DropDownList appropriately.

    One page1 you would have...

    <a href="page2.aspx?option=3">link to page 2</a>
    

    In the codebehind of page2, based on Al's example...

    void Page_Load(object sender, EventArgs e) {
       if (!Page.IsPostBack) {
          int option;
          if(int.TryParse(Request.QueryString["option"], out option) { //Only set the value if it is actually an integer
             ddlList.SelectedIndex = option;
          }
       }
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作