如果我从页面加载内部调用 webservise,如何让我的 ASP.net Web 服务向我的页面添加控件?
下面是我的代码的一个非常简化的版本。谢谢
''''''''''''''''''page code behind'''''''''''''''''''''''''''''''''''''''''''''''
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim m As New myWebService.Service
m.DoThis()
End Sub
End Class
''''''''''''''''''''''Web service'''''''''''''''''''''''''''''''''''''''
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://test.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class Service
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function DoThis() As String
Dim pg As Page = DirectCast(HttpContext.Current.Handler, Page)
Dim txtb As HtmlButton = New HtmlButton()
txtb.InnerText = "my bu-----tton"
pg.Form.Controls.Add(txtb)
Return "added"
End Function
End Class