CodeVerge.Net Beta


   Explore    Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > NEWSGROUP > Asp.Net Forum > general_asp.net.master_pages_themes_and_navigation_controls Tags:
Item Type: NewsGroup Date Entered: 3/28/2006 10:02:36 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
NR
XPoints: N/A Replies: 7 Views: 53 Favorited: 0 Favorite
8 Items, 1 Pages 1 |< << Go >> >|
jcakec
Asp.Net User
How to code Masterpage Events?3/28/2006 10:02:36 PM

0

Hello, I want to add some specific funcionality to a masterpage, where it does some processing, but when I add the event (e.g. xButton_click) it doesn't gets executed when the butotn is clicked...

do I have to code the event in every single page that uses the master page for it to work? I don't think so, because then it wouldn't serve as master page... :(

 

jminond
Asp.Net User
Re: How to code Masterpage Events?3/28/2006 10:09:04 PM

0

You should be bale to attach code to the master page code behind. so make sure your button_click is there. or in the <Script runat="server".....
You certainly dont need the event in every page.

Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
jcakec
Asp.Net User
Re: How to code Masterpage Events?3/28/2006 10:13:01 PM

0

jminond,

I have the code added, but it doesn't gets executed... even though the form gets submitted.

 

jminond
Asp.Net User
Re: How to code Masterpage Events?3/29/2006 12:21:39 PM

0

can you send me a zip of your master and page, with the byutton and code, and ill have a look?

jminond at gmail dot com


Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
cipher_nemo
Asp.Net User
Re: How to code Masterpage Events?3/29/2006 3:01:40 PM

0

I am experiencing the same problem, but I think I found out 'how', just not the 'why'.  The master page renders all content to your ContentPlaceHolder on the master page.  I've set stops and examined when this bypasses my wired-up events.

It turns out that if you're using something like a menu that 'navigates' to different files in your web project, that act of navigating bypasses any wired events on the mater page.  In other words, if you have a Menu on your master page that is not assigned a "NavigateUrl" property, the master page triggers its own events, sets the menu selected item, and does not change the content.

I don't know why it functions this way. This means the css pseudo-element :selected will not be rendered when a Menu in the master page navigates to a content page.  It only occurs when it doesn't navigate.

Very odd and frustrating.  I'd like my site to make use of its css pseudo-element :selected and run its wired-up events when triggered.  Specifically, I'm having problems catching my "MenuItemClick" event in my master page when my Menu uses it NavigateUrl value to render the ContentPlaceHolder.

1.) How can I manually designate the uri/file for the ContentPlaceHolder and render it

~or~

2.) How can I get the Menu to properly make use of the css pseudo-element :selected and allow the master page to trigger the MenuItemClick event for each content page a user visits via the NavigateUrl property of a MenuItem?

Here's my code so far (I've nixed the using statements and other obvious lines, as well as removed my styling so it's less confusing)...

Default.master.cs


public

partial class _Default : System.Web.UI.MasterPage
{
   protected void Page_Load(object sender, EventArgs e)
   {
      //wire-up events
      this.menuMain.MenuItemClick += new MenuEventHandler(menuMain_MenuItemClick);
      if (IsPostBack == false)
          
//set default page header
         lbl_Header.Text = "Home";
   }

   void menuMain_MenuItemClick(object sender, MenuEventArgs e)
   
{
      
//set page header
      lbl_Header.Text = menu_MainNavigation.SelectedValue;
      //set content
      //?how do I manually update content instead of using the NavigatUrl of Menu?
      //contentMain. ??  = menu_MainNavigation.Text + ".aspx".;
      //would I have to render contentMain manually, and is it possible?
   
}
}

Default.master


<asp:Menu
   id="menuMain"
   orientation="Vertical"
   runat="server">
   <Items>
      <asp:MenuItem
         Text="somePage"
         Value="1st Page Header"
         NavigateUrl="somePage.aspx" />
      <asp:MenuItem
         Text="anotherPage"
         Value="2nd Page Header" />
   </Items>
</asp:Menu>

<asp:ContentPlaceHolder id="contentMain" runat="server" />

 


Thanks!


private object yummyFood(baggels,coffee){
foreach(byte in (baggles).code){eat[byte];drink(coffee);}
return discharge(burp);}
jcakec
Asp.Net User
Re: How to code Masterpage Events?3/30/2006 10:29:21 PM

0

I found the error... the MasterPage doesn't fire events from generic names (at least for me)... I was using ImageButton1 as ID of the control and the event never got fired... once I changed the ID to something else imgBtnSearch, it worked...

asp.Net 2.0 comes with pretty weird bugs and behaviors... I hope Microsoft releases a more stable version soon...

regards,

JC

jminond
Asp.Net User
Re: How to code Masterpage Events?3/31/2006 12:33:03 PM

0

This is not the case, in the zip i returned to you, the image was called ImageButton1, was in the master, and the event fired.

Like I told you, at least in the code you showed me, your event was never wired to your image. Maybe when you changed the id in the designer, you reattached teh event, so now it works.

 

Im also not sure what else you mean by pretty weird bugs and behaviors, maybe you can explain specifics, and we can discuss them, these forums are watched by the asp.net team and leaders, so if we bring up soething thats really an issue, I am sure they will work on it.


Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
jcakec
Asp.Net User
Re: How to code Masterpage Events?4/2/2006 10:23:32 PM

0

thank you jimond, all the weird bugs and behaviors are actually being discussed in the forums, one of them is the Validation of viewstate MAC failed problem that raises when using DataGrids and Masterpages, where the __VIEWSTATEENCRYPTED never gets written, or the fact (this is more an IE issue than ASP.Net) that you cannot have an HTML form inside the ASP form as this makes the site useless (unless you use some other browser).

 

8 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Pro Asp.Net 2.0 In C# 2005 Authors: Matthew Macdonald, Mario Szpuszta, Pages: 1256, Published: 2005
Beginning ASP.NET 3.5 in C# 2008: From Novice to Professional Authors: Matthew MacDonald, Pages: 954, Published: 2007
Pro Asp.Net 2.0 In Vb 2005 Authors: Laurence Moroney, Matthew Macdonald, Matthew Macdonald, Pages: 1292, Published: 2006
Beginning ASP.NET 3.5 in VB 2008: from novice to professional Authors: Matthew MacDonald, Pages: 956, Published: 2007
Pro ASP.NET 2.0 in VB 2005 Authors: Laurence Moroney, Matthew MacDonald, Pages: 1253, Published: 2006

Web:
Master Page Events and User Controls - ASP.NET Forums I decided to create an Event on the Master page and then try to bind the user control to that event. When I step through my code everything looks ok until I ...
Page 3 - Incorporating Classes with Master Pages - Using VS ... To use this new event, you need to create an event handler, and then tie it to the event on the master page. Normally, the code for creating the tie-in ...
Master page events i have save, delete, clear buttons on masterpage. i want to write code to fire event when i click those buttons from content page. how to ...
2.0 Masterpage events before OnLoad? how can I set events other than Page_OnLoad for masterpage in 2.0? Because I need to have some code being run before the content page OnLoad ...
.NET - ASP.NET MasterPages and User Defined Events In the code above, CustomArgs inherits EventArgs. This means that when we raise an event in the master page, a reference to CustomArgs will ...

Error trying to dynamicaly change the master page behind the ... To set a master page dynamically, you need to make sure that the code runs in the Page_PreInit event. Does the above code run in the ...
Can't change control in Master Page - ng.asp-net-forum ... The page outputs "Master Page" but I want it to show "Content Page". Can anyone figure out what is going on? Here's most of the code: ...
Conflict between onerror and onasyncpostbackerror events - asp ... Is someone suggests the complete code ... with master page, update panels on a page and onerror and onasyncpostbackerror events implemented? ...
SiteMapResolve event, global.asax and defaultProvider - ng.asp-net ... Thus, it appears as if the event handling code is still attached to the default ... master page content place holder changes shape ...
Master Page Causing Focus Loss - asp.net_ajax.asp.net_ajax_ui Focus() in the UpdatePanel's PreRender event but that has not helped me. In stepping through the execution it appears that it executes the page level code ...












treeview selectednodechanged before page_load

problem setting textbox color from a skin

change image in treeview node when it expands

changing treeview items image without postpack

meta tags and masterpages

interact with masterpage code from content page.

error on custom providers

has anyone used themes and skins with master pages?

master page path problem - loading it

conflict with system.web.ui.masterpage / myown base class

how to expand treeview to specific node on page load when using populateondemand???

wizard (webform) writes twice to database.

jumbled controls on master page

adding javascript to master pages!!

binding sitemap to tree view control in a user control causes problems

how can i change the currentsitemapnode title ?

changes to master page and style sheet not effected throughout project

simple button/image-based menu

literal control not allowed within skin file???

controls with skinids vs controls without skinids - what's the hierarchy ?

need advice on how to implement menu

menu server control and ie whitespace

seeting color to row of a gridview based on some condition

master page in different proj

sitemappath with image as pathseparator?

navigation treeview control - expanding and collapsing

retain value in iframe of master page

sitemappath control

moving straight html to masterpage

master page issues with sqldatasource

 
Search This Site:

 
  Privacy | Contact Us
All Times Are GMT