Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 10th, 2004, 01:38 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
  #2 (permalink)  
Old November 10th, 2004, 02:36 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
  #3 (permalink)  
Old November 10th, 2004, 02:58 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
  #4 (permalink)  
Old November 10th, 2004, 03:09 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
  #5 (permalink)  
Old November 10th, 2004, 03:16 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
  #6 (permalink)  
Old November 10th, 2004, 03:21 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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

Reply With Quote
  #7 (permalink)  
Old November 10th, 2004, 03:22 AM
Authorized User
 
Join Date: Jul 2003
Location: , , .
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.

Reply With Quote
  #8 (permalink)  
Old November 10th, 2004, 03:43 AM
Friend of Wrox
 
Join Date: Jun 2004
Location: Chennai, Tamil Nadu, India.
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
Reply With Quote
  #9 (permalink)  
Old November 10th, 2004, 11:39 AM
Friend of Wrox
 
Join Date: Sep 2004
Location: , , India.
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...


Reply With Quote
  #10 (permalink)  
Old November 10th, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Sep 2004
Location: , , India.
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...

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 04:41 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.