当前位置:编程学习 > C#/ASP.NET >>

用户控件问题

我通过Javascript 调用服务器方法动态添加了一个用户控件,然后页面上还有一些其它的按钮,我想在点击这些按钮的时候改变这个添加的用户控件中的某些控件的值,代码已经执行了,但是用户控件中的值没有任何变化。具体代码如下:

1 客户端:
function Button1_onclick() {
    ShowSalesQuotationMainView(onSuccessCallback, onFailureCallback); // ShowSalesQuotationMainView 是服务器端的方法
}

function onSuccessCallback(result)
{
    alert("onSuccessCallback");
    
    var elem = $get("mainContent");
    elem.innerHTML = result;
    
}

function onFailureCallback()
{
    alert("onfailureCallback");
}

2 服务器端:
    <WebClientMethod()> _
    Public Shared Function ShowSalesQuotationMainView() As String
        Return GetHmtlFromUserControl("~/Sales/SalesQuotationMainView.ascx")
    End Function

    Private Shared Function GetHmtlFromUserControl(ByVal url As String)
        Dim page As New Page()
        Dim control As Control = page.LoadControl(url)
        control.EnableViewState = False
        Dim form As New HtmlForm
        form.Controls.Add(control)
        page.Controls.Add(form)
        Dim writer As New IO.StringWriter()
        HttpContext.Current.Server.Execute(page, writer, False)
        Dim html As String = writer.ToString
        Return Regex.Replace(html, "<[/]?(form)[^>]*?>", "", RegexOptions.IgnoreCase)
    End Function

3. 当我点击页面上某个按钮时(并非用户控件上的按钮),用户控件中的这个方法会被调用,但是界面上的值没有变化。
    Public Sub SetCardCode(ByVal text As String) 
        Me.txtCardCode.Text = text
     End Sub

请各位朋友帮忙看看如何解决, 谢谢。 --------------------编程问答-------------------- 用ajax
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,