iT邦幫忙

0

[筆記系列]UserControl uc在aspx使用自定義Tag,抓取存為ViewState方法

<%--在aspx(html)引用的uc--%>
<%@ Register Src="~/路徑就對了/ABC.ascx" TagPrefix="TagPrefixName" TagName="TagName" %>

<%--在aspx(html)使用的uc--%>
<TagPrefixName:TagName runat="server" ID="YourId" Tag_Text="自訂的Tag"/>


//ABC.ascx.vb

//使用的function vb
Protected Sub BT_S_C_1_Click(sender As Object, e As EventArgs) Handles BT_S_C_1.Click

    Dim sNumid As String = Page.Request("num_id")
    Dim sProcess As String = ViewState("YourTag")

    //do something ~~~~~
End Sub

//Tag_Text() 主要這個 vb
Public Property Tag_Text() As String
    Get
        Return ViewState("YourTag")
    End Get

    Set(ByVal value As String)
        ViewState("YourTag") = value

    End Set
End Property

//-----------------------補充---------------------
//UserControl 呼叫 父網頁的Function

    Dim p As Page = Me.Parent.Page
    Dim pageType As Type = p.GetType()
    Dim reUrl As MethodInfo = pageType.GetMethod("function名字")
    reUrl.Invoke(p, New Object() {"參數1","參數2","參數3"})

尚未有邦友留言

立即登入留言