473,811 Members | 3,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling procedure in Masterpage from User Control

Hello...

I have this UserControl (login.ascx -Login), that is placed in a
Masterpage (Layout.master -Layout).

How can I call a sub (RedrawMenu) that is place in the code-behind of the
master page from within a sub inside the UserControl???

i'm having all this issues because all the components are inseide
UpdatePanels, to avoid the whole page reload.. but know, the function is not
being called...

Searching the web, i've found something like this:
Dim cmp As CustomMasterPag e = CType(Master, CustomMasterPag e)

But since i'm in an User Control, it doesn't work...
tks in advance...
Christiano
Nov 21 '08 #1
4 4438
ok...so I should replace the MasterPage1 by my Masterpage name, right???

so it will be:
Layout m = this.Page.Maste r as Layout;
m.RedrawMenu();

since i'm using VB:
Dim m as Layout = TryCast(Me.Page .Master, Layout)
m.RedrawMenu

But VS is complainig that "Layout is not defined"

should i have it declared somewhere before?
tks..
"Jérémy Jeanson" <je************ @free.frescreve u na mensagem
news:uG******** ********@TK2MSF TNGP04.phx.gbl. ..
To do, you have to write RedrawMenu as public methode and in the
UserControl you have to user the Master property of the Page

Exemeple:

// in you master (MasterPage1)co de-behind:

public void RedrawMenu()
{

}

// In the UserControl :

MasterPage1 m = this.Page.Maste r as MasterPage1;
m.RedrawMenu();

--
Jérémy JEANSON
MCP
http://jeremy.blogdns.net

Nov 21 '08 #2
while this is a giood design practice, the simple solution is to use the
@MasterType directive which will type the Master page property for you, so no
casts are required.

-- bruce (sqlwork.com)
"Jérémy Jeanson" wrote:
Damn...

You have this isue because your project is a website, not an application.

To solve this, you have 2 ways:
1) use a web application

2) create an interface that will be use by your masterpage

Public Interface ILayout
Sub RedrawMenu()
End Interface

Partial Public Class Layout
Inherits System.Web.UI.M asterPage
Implements ILayout

Public Sub RedrawMenu() Implements ILayout.RedrawM enu

End Sub
End Class

Partial Class WebUserControl
Inherits System.Web.UI.U serControl

Public Sub New()
Dim m As ILayout = TryCast(Me.Page .Master, ILayout)
m.RedrawMenu()
End Sub
End Class

--
Jérémy JEANSON
MCP
http://jeremy.blogdns.net
Nov 21 '08 #3
Is it bad to be a Web Site and not a WebApplication? ??

I've tried converting it to an application... But.. Can I still use ajax?
and other components???

I figured out already that the Web.Config has been replaced by the
Settings.vb file..
What about the Authentication/Authorization statements???
I usually use Web Site projects and not the Web

(Both lame questions, but I need to ask it... lol)

"Jérémy Jeanson" <je************ @free.frescreve u na mensagem
news:%2******** **********@TK2M SFTNGP06.phx.gb l...
Damn...

You have this isue because your project is a website, not an application.

To solve this, you have 2 ways:
1) use a web application

2) create an interface that will be use by your masterpage

Public Interface ILayout
Sub RedrawMenu()
End Interface

Partial Public Class Layout
Inherits System.Web.UI.M asterPage
Implements ILayout

Public Sub RedrawMenu() Implements ILayout.RedrawM enu

End Sub
End Class

Partial Class WebUserControl
Inherits System.Web.UI.U serControl

Public Sub New()
Dim m As ILayout = TryCast(Me.Page .Master, ILayout)
m.RedrawMenu()
End Sub
End Class

--
Jérémy JEANSON
MCP
http://jeremy.blogdns.net

Nov 21 '08 #4
"Christiano Donke" <cd****@digiexp ress.com.brwrot e in message
news:ep******** ******@TK2MSFTN GP06.phx.gbl...
>You have this isue because your project is a website, not an application.

To solve this, you have 2 ways:
1) use a web application

Is it bad to be a Web Site and not a WebApplication? ??
Matter of opinion - I never use the website model...
I've tried converting it to an application... But.. Can I still use ajax?
and other components???
Yes.
I figured out already that the Web.Config has been replaced by the
Settings.vb file..
Ah - sounds like you've converted your website to a WinForms application,
not a web application...
--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Nov 21 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2177
by: Steven K | last post by:
Hello, In my codebehind file, I am trying to call a sub procedure that is in my MasterPage, but I am getting an error: Error 1: BC30451: Name 'LoadMenu' is not declared. c:\inetpub\wwwroot\price_insx\MenuCode.aspx.vb 19 ---- Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
9
1915
by: User | last post by:
OK, I asked in a reply, but I've wasted far too long so I'm going to put a new post out there in hopes that it will be more visible. I have a MasterPage. I want to call a method declared in that class from a Page that uses the MasterPage. How do I do that? public partial class List : System.Web.UI.MasterPage { protected ArrayList m_SortList;
1
1882
by: rh | last post by:
Hi, My MasterPage contains a user control used for navigation. I have some .aspx pages that use this MasterPage and I would like to cache only the user control used for navigation. How do I go about doing so? I know that I can cache specific controls on a page by setting the VaryByControl property of the OutputCache directive. But if the control is
2
7702
by: dawg1998 | last post by:
I have a page that creates dynamic textboxes based on the number of fields a user chooses to fill out. This process worked great when the page was standalone. However, when I move to a Content/MasterPage setup, the MasterPage Form seems to be interfering with the ability of my code to retrieve the value in the dynamic control. Are there any ideas on why this is happening or how to work-around the problem? What is the syntax to find a...
5
1744
by: Islamegy® | last post by:
In my project i have two master page which i change dynamic in runtime.. The first one with 1 ContentPanel "onepanel.master", the second with 2 contentPanel"twopanel.master".. but when i switch between them it don't work, if the default masterpage is "onepanel.master" and try to change it in runtime, ContentPanel2 which is exist in the loaded masterpage throw exception.. the same happen if the default is "twopanel.master" and switch it...
0
1169
by: benjamin.soulier | last post by:
Hello everyone, here is the problem I got : I have a Base Web User Control (like a user control containing a border, for design purpose). In this User Control, I put a PlaceHolder, and I put a Property to access this PlaceHolder from outside. Then I put in a MasterPage the Base Web User Control, and then i use in MasterPage code behind to add a Web User Control as content of Base User Control :
5
4049
by: sck10 | last post by:
Hello, I am converting a class in the App_Code folder from c# to vb and am having problems calling the sub procedure. I have created a Sub called HidePanels in the class "General". When I try to declare a new object of this type in my codebehind, I get the error: "Type 'HidePanels' is not defined". Any help with this would be appreciated. Thanks, sck10 code behind ===========
2
2377
by: Rissoman | last post by:
I have two user controls on a master page. I can easily bubble up an event on usercontrol 1 from a click event to the page.aspx, than then calls a method on the masterpage, but this causes the screen to do a postbacka nd full load. What I'm doing is i have a button on one user control that when clicked it will dynamically load a usercontrol into a placeholder on the masterpage. I know that if I were to put everything into an update...
2
2210
by: =?Utf-8?B?RGFsZQ==?= | last post by:
I have an app with a MasterPage. In the MasterPage is a user control with several public properties and methods that I want exposed to the content page. Rather than writing several redirection methods to expose the properties, I would rather just expose the user control as a property of the MasterPage. The problem is, when I compile, I get an exception on the content page: The type 'MessageBlock.MessageBlock' is defined in an...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6893
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5697
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4342
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.