Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

Stack Overflow Error when clicking on MasterPage link.

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
thomasjgregg@yahoo.com - 17 Mar 2008 00:38 GMT
I have a menu in the masterpage.  It all works great until I click on
the link that transfers to the page that I am on.  When I do this it
causes a stack overflow error.  I can see why it is doing this but I
am not sure what to do to fix it.  Any Help would be appreciated.

The code:
   <table cellspacing=0 cellpadding=5 width=770 border=0>
       <tr>
           <td width=130 valign=top>
               <asp:LinkButton ID="HomeLink" runat="server"
CssClass="MenuLink" NavigateUrl="Default.aspx"
OnClick="HomeLink_Click">Home</asp:LinkButton><br />
               <asp:LinkButton ID="AboutUsLink" runat="server"
CssClass="MenuLink" NavigateUrl="AboutUs.aspx"
OnClick="AboutUsLink_Click">About Us</asp:LinkButton><br />
               <asp:LinkButton ID="HowWeCanHelpLink" runat="server"
CssClass="MenuLink" NavigateUrl="HowWeCanHelp.aspx"
OnClick="HowWeCanHelpLink_Click">How we can help</asp:LinkButton><br /

               <asp:LinkButton ID="ProductLink" runat="server"
CssClass="MenuLink" NavigateUrl="Product.aspx"
OnClick="ProductLink_Click">Product</asp:LinkButton><br />
               <asp:LinkButton ID="ContactUsLink" runat="server"
CssClass="MenuLink" NavigateUrl="ContactUs.aspx"
OnClick="ContactUsLink_Click">Contact Us</asp:LinkButton><br />
           </td>
           <td valign=top style="border-left:1px solid black;" >
                   <asp:ContentPlaceHolder ID="MainHolder"
runat="server"></asp:ContentPlaceHolder>
           </td>
       </tr>
   </table>

public partial class MasterPage : System.Web.UI.MasterPage
{
   User u = new User();
   protected void Page_Load(object sender, EventArgs e)
   {
       if (!Session.IsNewSession & !IsPostBack)
       {
           u.GetUserByUserName(Session["UserName"].ToString());
           UserLabel.Text = u.FirstName;
       }
   }
   protected void AboutUsLink_Click(object sender, EventArgs e)
   {
           Session.Add("UserName", u.UserName);
           Server.Transfer("AboutUs.aspx", true);
   }
   protected void HomeLink_Click(object sender, EventArgs e)
   {
           Session.Add("UserName", u.UserName);
           Server.Transfer("Default.aspx", true);
   }
   protected void HowWeCanHelpLink_Click(object sender, EventArgs e)
   {
           Session.Add("UserName", u.UserName);
           Server.Transfer("HowWeCanHelp.aspx", true);
   }
   protected void ProductLink_Click(object sender, EventArgs e)
   {
           Session.Add("UserName", u.UserName);
           Server.Transfer("Product.aspx", true);
   }
   protected void ContactUsLink_Click(object sender, EventArgs e)
   {
           Session.Add("UserName", u.UserName);
           Server.Transfer("ContactUs.aspx", true);
   }
}
Peter Bromberg [C# MVP] - 17 Mar 2008 17:04 GMT
Why don't you just check to see what the current page is? If it is the same
as the link that was clicked, just return from the method and do nothing.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net

> I have a menu in the masterpage.  It all works great until I click on
> the link that transfers to the page that I am on.  When I do this it
[quoted text clipped - 66 lines]
>     }
> }

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.