Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Stack Overflow Error when clicking on MasterPage link.

Reply
Thread Tools

Stack Overflow Error when clicking on MasterPage link.

 
 
thomasjgregg@yahoo.com
Guest
Posts: n/a
 
      03-16-2008
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);
}
}
 
Reply With Quote
 
 
 
 
Peter Bromberg [C# MVP]
Guest
Posts: n/a
 
      03-17-2008
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


"(E-Mail Removed)" wrote:

> 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);
> }
> }
>

 
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
C/C++ compilers have one stack for local variables and return addresses and then another stack for array allocations on the stack. Casey Hawthorne C Programming 3 11-01-2009 08:23 PM
Why stack overflow with such a small stack? Kenneth McDonald Ruby 7 09-01-2007 04:21 AM
MasterPages - take plain form, add MasterPage. MasterPage does NOT appear when run Randy Smith ASP .Net 9 04-14-2007 09:06 AM
MasterPage inheriting a MasterPage... is it possible? ThunderMusic ASP .Net 2 09-27-2006 07:57 PM
MasterPage -> Page -> MasterPage Code Access =?Utf-8?B?QWxleCBNYWdoZW4=?= ASP .Net 3 04-14-2006 12:34 PM



Advertisments