473,320 Members | 1,861 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 CustomMasterPage = CType(Master, CustomMasterPage)

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

so it will be:
Layout m = this.Page.Master 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.frescreveu na mensagem
news:uG****************@TK2MSFTNGP04.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)code-behind:

public void RedrawMenu()
{

}

// In the UserControl :

MasterPage1 m = this.Page.Master 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.MasterPage
Implements ILayout

Public Sub RedrawMenu() Implements ILayout.RedrawMenu

End Sub
End Class

Partial Class WebUserControl
Inherits System.Web.UI.UserControl

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.frescreveu na mensagem
news:%2******************@TK2MSFTNGP06.phx.gbl...
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.MasterPage
Implements ILayout

Public Sub RedrawMenu() Implements ILayout.RedrawMenu

End Sub
End Class

Partial Class WebUserControl
Inherits System.Web.UI.UserControl

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****@digiexpress.com.brwrote in message
news:ep**************@TK2MSFTNGP06.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
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....
9
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...
1
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...
2
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...
5
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...
0
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...
5
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...
2
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...
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.