Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page.

Reply
Thread Tools

Accessing USER CONTROL which is inside Masterpagethrough Another USER Control inside normal page.

 
 
Kiran More
Guest
Posts: n/a
 
      11-13-2006
I have created a lable in the InfoMessageBox.ascx control.
This control in used in Master Page.

One Page is designed by making use of this Master Page.
This ASPX is having another user control.

This user control has got one buttong which on click makes database call.

The response returned after clicking the above button, i.e. either Error or Success, the label from InfoMessageBox will be set.

Now I am unable to access the LABEL control Which is inside InfoMessageBox.ASCX which is used inside the Master Page.

Please help me in this.

kiran
 
Reply With Quote
 
 
 
 
MikeS
Guest
Posts: n/a
 
      11-13-2006
Some may suggest you do a Master.FindControl to get the master pages
label control to set its properties directly.

But maybe put a property in the master page that in turn sets a
property on its user control that then sets the label controls text.

And also have the button web control raise an event when the status
changes and in its pages handler for that call the master pages
property let.

That way the interaction is between the control and the page, the page
and it's master, and the master and it's control, and not directly
between the two controls.


So in the button user control

Public Event StatusChanged(ByVal s As String)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Button1.Click
RaiseEvent StatusChanged(Guid.NewGuid.ToString)
End Sub

And in the page that contains it.

Protected Sub WebUserControl1_StatusChanged(ByVal s As String)
Handles WebUserControl1.StatusChanged
Dim mp As TheMasterPage = Me.Master
mp.NewStatus = s
End Sub

And in the master page.

Public WriteOnly Property NewStatus() As String
Set(ByVal value As String)
WebUserControl2_1.StatusText = value
End Set
End Property

And in the label user control.

Public WriteOnly Property StatusText() As String
Set(ByVal value As String)
Label1.Text = value
End Set
End Property


It may seem like a lot of code up front but going forward any page can
set the status with just this.

Dim mp As TheMasterPage = Me.Master
mp.NewStatus = "Whatever"

This will have to be changed to use an interface that all master pages
implement if you ever get around to wanting to change the master page
of the site on the fly.

 
Reply With Quote
 
 
 
 
Kiran More
Guest
Posts: n/a
 
      11-14-2006
Hi Mike,

Thanks a lotttttttttttt......
really great...


thanks again....

kiran more
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing values of a control which is in a user control =?Utf-8?B?U3Jpbmk=?= ASP .Net 1 11-02-2006 08:53 AM
Custom User Control is not rendered inside another user control in a server table. Leeor Chernov ASP .Net 2 10-16-2005 08:35 AM
accessing the web user control's control from a web page and set a value from another web page Reny J Joseph Thuthikattu ASP .Net 1 12-30-2004 12:21 PM
How to access: a page from a User control, and another User controlfrom another one? qwerty ASP .Net 3 09-30-2004 05:32 PM
Access a control inside an usercontrol from another control inside another usercontrol nail ASP .Net 0 09-15-2004 03:55 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57