Hi been searching for the whole week to solve my problem but I still haven't fegure it out.
how to Update my user control without closing the modal popup,
I'm loading a user control programmatically from my Master Page/Main Page
Default.aspx.vb
Protected Sub img1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img1.Click
Dim u As Control = LoadControl("~/WebUserControl.ascx")
Dim txt As New TextBox
txt = CType(u.FindControl("txtName"), TextBox)
txt.Text = "Michel"
UcPlaceHolder.Controls.Add(u)
MPEUC.Show()
End Sub
Partial Class WebUserControl
Inherits System.Web.UI.UserControl
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub txtAge_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtAge.TextChanged
Me.output.Text = String.Format("I`m {0} years old.", Me.txtAge.Text)
End Sub
Protected Sub txtName_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtName.TextChanged
Me.output.Text = String.Format("Hi!, my name is {0}. ", Me.txtName.Text)
End Sub
End Class
Your problem is due to the fact that you adds the control programmatically which when you are doing a PostBack actually removes the control from the Page and the events of the text boxes will never get fired, to be able to catch those events you will have
to readd the control when it is being posted back, like for example in your code:
Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Page.IsPostBack Then
Dim target As String = Page.Request.Form("__EVENTTARGET")
If target = "ctl02$txtAge" Or target = "ctl02$txtName" Then
Dim u As WebUserControl = LoadControl("~/WebUserControl.ascx")
UcPlaceHolder.Controls.Add(u)
End If
End If
End Sub
Protected Sub img1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles img1.Click
Dim u As WebUserControl = LoadControl("~/WebUserControl.ascx")
Dim txt As New TextBox
txt = CType(u.FindControl("txtName"), TextBox)
txt.Text = "Michel"
UcPlaceHolder.Controls.Add(u)
MPEUC.Show()
End Sub
End Class
Member
3 Points
46 Posts
Dynamic UserControl Textchange won't fire inside modal popup
Jan 30, 2014 03:29 AM|iMaker.ph|LINK
Hi been searching for the whole week to solve my problem but I still haven't fegure it out.
how to Update my user control without closing the modal popup,
I'm loading a user control programmatically from my Master Page/Main Page
Default.aspx.vb
My User Control
WebUserControl.ascx.vb
Participant
1390 Points
323 Posts
Re: Dynamic UserControl Textchange won't fire inside modal popup
Jan 30, 2014 06:33 AM|valuja|LINK
Hi,
Your problem is due to the fact that you adds the control programmatically which when you are doing a PostBack actually removes the control from the Page and the events of the text boxes will never get fired, to be able to catch those events you will have to readd the control when it is being posted back, like for example in your code:
Not the most elegant way but it works.
Best regards
Johan
Member
3 Points
46 Posts
Re: Dynamic UserControl Textchange won't fire inside modal popup
Jan 30, 2014 10:00 AM|iMaker.ph|LINK
I'll try it on office hour
by adding
on my Main page things are working fine.
Thanks
BTW
would you mind help me with this scenario
http://forums.asp.net/p/1964530/5616384.aspx?p=True&t=635266728130866218&pagenum=1
Thanks :)
All-Star
48393 Points
12161 Posts
Re: Dynamic UserControl Textchange won't fire inside modal popup
Jan 31, 2014 08:39 AM|chetan.sarode|LINK
Refer to this: How to keep ModalPopupExtender after full PostBack?
http://patelshailesh.com/index.php/why-does-modalpopup-close-on-postback
Team Lead, Product Development
Approva Systems Pvt Ltd, Pune, India.