单击后如何获取动态创建的链接的路径? [英] How can I get the path of a dynamically created link when clicked?

查看:57
本文介绍了单击后如何获取动态创建的链接的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:-

This is my code:-

string stringChapterno = Session["chapterno"].ToString();
          string stringAppPath = HttpContext.Current.Request.ApplicationPath;
          string stringPhysicalPath = HttpContext.Current.Request.MapPath(stringAppPath);
          stringPhysicalPath = stringPhysicalPath + "\\App_Data\\" + stringChapterno;
          //List<string> dirs = GetFilesRecursive(stringPhysicalPath);

          foreach (string p in Directory.GetDirectories(stringPhysicalPath))
          {
              LinkButton blink = new LinkButton();
              string s=Path.GetFileNameWithoutExtension(p);
              blink.Text = s;
              blink.CssClass = "hyperlink";

              Panel1.Controls.Add(blink);
              Panel1.Controls.Add(new LiteralControl("<br>"));
              Panel1.Controls.Add(new LiteralControl("<br>"));
              blink.PostBackUrl="QuestionPaper.aspx";
          }



现在我想知道如何获取眨眼的路径?



Now I want toknow How can I get the path to blink?

推荐答案

眨眼的路径"是什么意思?
如果您谈论的是网页中的位置,则将其添加到Panel1中,如果需要,可以使用类似以下内容的方式找到:
What do you mean by ''path to blink''?

if you are talking of location in webpage, it was added to Panel1 and if needed can be found by using something like:
Panel1.FindControl()


您可以使用Linq-to-XML解析a标记并检索href属性.
You could use Linq-to-XML to parse the a tag and retrieve the href attribute. That will give you the link itself.


您要查找的是绝对URL而不是"questionpaper.aspx"吗?

如果是这样,请尝试
Are you looking for the absolute URL instead of ''questionpaper.aspx''?

If so, try like
Page.ResolveClientUrl("~/App_Data/ " + stringChapterno + "QuestionPaper.aspx")


这篇关于单击后如何获取动态创建的链接的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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