【问题标题】:Please help to solve the following code请帮忙解决以下代码
【发布时间】:2014-03-19 05:58:32
【问题描述】:

我正在尝试在 url (localhost/fca/htp/home.aspx) 中捕获页面名称。这是第一次。第一次加载页面时 indexofdot 取值为 4 ,即主页。但是当页面刷新或者当我们在访问其他页面后再次返回主页时,它的值是 5,这是错误的。我尝试 page.ispostback 在刷新时跳过,但它不起作用。 提前谢谢你

If String.IsNullOrEmpty(PageName) Then 'Probably the home page

        Dim PathComponents As String() = Request.FilePath.Split("/")
        Dim indexOfDot As Integer = PathComponents(PathComponents.Length - 1).IndexOf(".")
        If indexOfDot > -1 Then
            PageName = PathComponents(PathComponents.Length - 1).Remove(indexOfDot)
        End If
    End If

【问题讨论】:

    标签: vb.net-2010


    【解决方案1】:

    把你的代码放在页面加载方法中,或者如果你需要在页面初始化中执行函数,在第一次加载的时候把一些值放在一个隐藏字段中,这样你就可以很容易地测试隐藏字段的值请求表格

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-01-15
      • 1970-01-01
      • 1970-01-01
      • 2016-04-21
      • 1970-01-01
      • 2021-02-05
      • 1970-01-01
      相关资源
      最近更新 更多