Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
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
 
Old November 10th, 2004, 01:38 AM
Authorized User
 
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to brettdavis4
Default 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

 
Old November 10th, 2004, 02:36 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

can u post the html of both controls??

Do you have the object declared in your code behind

Regards
Ganesh
 
Old November 10th, 2004, 02:58 AM
Authorized User
 
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to brettdavis4
Default

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

 
Old November 10th, 2004, 03:09 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

Why have you declared hpl1 twice in your code??

Did you not define hpl2 in your aspx page??

Regards
Ganesh
 
Old November 10th, 2004, 03:16 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

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
 
Old November 10th, 2004, 03:21 AM
Authorized User
 
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to brettdavis4
Default

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

 
Old November 10th, 2004, 03:22 AM
Authorized User
 
Join Date: Jul 2003
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to brettdavis4
Default

I get the error on page load.

 
Old November 10th, 2004, 03:43 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 449
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to r_ganesh76
Default

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
 
Old November 10th, 2004, 11:39 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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...


 
Old November 10th, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Sep 2004
Posts: 140
Thanks: 0
Thanked 0 Times in 0 Posts
Default

sorry i missed else ur html code will not have proper code for the controls...






Similar Threads
Thread Thread Starter Forum Replies Last Post
( C# in ASP.NET ) can a hyperlink call a function? richie86 ASP.NET 1.0 and 1.1 Basics 0 November 5th, 2005 01:25 AM
Problem with Exercise in Beg. asp.net for VB.net! mrfella71 BOOK: Beginning ASP.NET 1.0 1 October 23rd, 2005 12:06 PM
ASP:Hyperlink problem widad Classic ASP Basics 3 September 23rd, 2004 10:42 AM
Hyperlink in asp.net Jaco Jordaan ASP.NET 1.x and 2.0 Application Design 6 November 28th, 2003 07:15 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.