Asp.net 当控件位于内容页上的更新面板内时更新母版页。我尝试了很多,但没有成功?

Asp.net 当控件位于内容页上的更新面板内时更新母版页。我尝试了很多,但没有成功?,asp.net,updatepanel,ajaxcontroltoolkit,master-pages,Asp.net,Updatepanel,Ajaxcontroltoolkit,Master Pages,您不能直接这样做,必须使用ScriptManager.RegisterStartupScript()函数,该函数将插入java脚本语句,该语句将在更新面板获取更新时执行。并添加java脚本语句以查找要更新的元素并设置其值 像下面的c代码一样,将其转换为VB并使用 Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click Master.settxtvalu

您不能直接这样做,必须使用ScriptManager.RegisterStartupScript()函数,该函数将插入java脚本语句,该语句将在更新面板获取更新时执行。并添加java脚本语句以查找要更新的元素并设置其值

像下面的c代码一样,将其转换为VB并使用

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

    Master.settxtvalue.Text = Me.TextBox1.Text
    Me.Button1 = TryCast(Me.Master.FindControl("mdlpp").FindControl("Button1"), Button)

End Sub


Public ReadOnly Property settxtvalue() As TextBox
    Get
        Return Me.TextBox18
    End Get
End Property
这里是更新面板id的UpdatePanel1。替换下面的代码行

string strUpdate = "document.getElementById('" + Master.settxtvalue.ClientID + "').value = '" + Me.TextBox1.Text + "'";
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "msupdate", strUpdate, true);
用它

这是VB版本

Master.settxtvalue.Text = Me.TextBox1.Text

您不能直接这样做,必须使用ScriptManager.RegisterStartupScript()函数,该函数将插入java脚本语句,该语句将在更新面板获取更新时执行。并添加java脚本语句以查找要更新的元素并设置其值

像下面的c代码一样,将其转换为VB并使用

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click

    Master.settxtvalue.Text = Me.TextBox1.Text
    Me.Button1 = TryCast(Me.Master.FindControl("mdlpp").FindControl("Button1"), Button)

End Sub


Public ReadOnly Property settxtvalue() As TextBox
    Get
        Return Me.TextBox18
    End Get
End Property
这里是更新面板id的UpdatePanel1。替换下面的代码行

string strUpdate = "document.getElementById('" + Master.settxtvalue.ClientID + "').value = '" + Me.TextBox1.Text + "'";
ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "msupdate", strUpdate, true);
用它

这是VB版本

Master.settxtvalue.Text = Me.TextBox1.Text