你好,我正在尝试从 url 获取 id 并将其发送到 clint 端,这就是我所做的
这是我的网址:
http://localhost:53010/edit.aspx?Id=4
后面的代码
Public Partial Class Edit
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
End Sub
Private _myId As String = Request.QueryString("id")
Public Property myId() As String
Get
Return _myId
End Get
Set(ByVal value As String)
_myId = value
End Set
End Property
端类客户端
<%= myId%>
错误
Request is not available in this context
这也是我将私有道具移动到 page_load() 时得到的结果“私有”在局部变量声明中无效——知道发生了什么
谢谢
我解决了这个问题,这就是答案
Public Partial Class Edit
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
MyIdVal = Request.QueryString("id")
End Sub
Private _myIdVal As String
Public Property MyIdVal() As String
Get
Return _myIdVal
End Get
Set(ByVal value As String)
_myIdVal = value
End Set
End Property
结束类