 |
| General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category.
** PLEASE BE SPECIFIC WITH YOUR QUESTION **
When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 10th, 2004, 01:38 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
asp.net hyperlink problem
:(:(:(:(:(:(
I have copied and pasted an <asp:hyperlink> from one control to a different one. On the first control everything works fine. On the one that I copied to, I get the following error:
Object reference not set to an instance of an object.
This is really F***ing pissing me off, so someone please help me out.
Thanks, Brett
|
|

November 10th, 2004, 02:36 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
|
|
can u post the html of both controls??
Do you have the object declared in your code behind
Regards
Ganesh
|
|

November 10th, 2004, 02:58 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ganesh,
Here is part of my codebehind:
protected System.Web.UI.WebControls.HyperLink hpl1;
namespace ewga.controls
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
/// <summary>
/// Summary description for photo.
/// </summary>
public class photo : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.HyperLink hpl1;
protected System.Web.UI.WebControls.HyperLink hpl2;
private void Page_Load(object sender, System.EventArgs e)
{
hpl1.NavigateUrl = "../photo.aspx?photoid=2&photocatid=2&tab=5";
}
//int photocatID = Convert.ToInt32(Request.QueryString["photocatid"].ToString());
//ewga.components.PhotoDB cats = new ewga.components.PhotoDB();
//int maxnum = 1 + Convert.ToInt32(cats.GetPhoto(photocatID).Tables[0].Rows.Count);
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
This is how i'm calling in my aspx page
<asp:HyperLink id="hpl1" runat="server" NavigateUrl="" CssClass="tdlink">< Back</asp:HyperLink>
Thanks, Brett
|
|

November 10th, 2004, 03:09 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Why have you declared hpl1 twice in your code??
Did you not define hpl2 in your aspx page??
Regards
Ganesh
|
|

November 10th, 2004, 03:16 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
|
|
A namespace does not directly contain members such as fields or methods.
However, I tried to use the same code as you've done in my page and its code behind and it was working perfectly well.
When do you get the error?? on pageLoad ???
Regards
Ganesh
|
|

November 10th, 2004, 03:21 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ganesh,
I made a typo. I was going to display just the reference to the hyperlink, but then I decided to just show all of the code. I just forgot to take out that first line. I am only referencing it once. I still get the error on that page. I might just start from scratch on a different page.
Thanks a bunch.
Brett
|
|

November 10th, 2004, 03:22 AM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I get the error on page load.
|
|

November 10th, 2004, 03:43 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
|
|
are you able to see the web control during design time??. in case you have any error in the definition, you will see an error in the design view
Regards
Ganesh
|
|

November 10th, 2004, 11:39 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
what exatly have u copy pasted code.. or the control.?
coz if u have pasetd control all u have to do is change the name...
|
|

November 10th, 2004, 11:40 AM
|
|
Friend of Wrox
|
|
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
sorry i missed else ur html code will not have proper code for the controls...
|
|
 |