Showing posts with label user control. Show all posts
Showing posts with label user control. Show all posts

Friday, September 9, 2011

How to render user control in asp.net with ajax

function yourfunction(val1) {
$.ajax({
type: "POST",
url: "..GetData.aspx",
data: 'param=ctlParam&qs=' + val1,
success: function (data) {
//do what you need
},
error: function (request, status, error) {
alert(request.responseText);
}
});
}


Use the code in .aspx page

Dim strparam As String = Request.Form("param")
Dim strResponse As String = ""
hshProperty.Add("qs", Convert.ToInt32(Request.Form("qs")))
strResponse = ViewManager.RenderUserControl("yourcontrol.ascx", hshProperty)

''qs will be property in yourcontrol.ascx

Response.Write(strResponse)