Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 29th, 2009, 12:53 PM
Authorized User
 
Join Date: Oct 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem in child page with Hyperlink.Attributes.Add

Hello All,

I am having a weird problem Hyerlink.Attribute.Add("onclick"). The code i am using is as foolwing -

HyperLink h1 =(HyperLink)Form.FindControl("hlnkPatienType");
h1.Attributes.Add("onclick", "window.open('TypePatient.aspx',null,'left=700 , top=50, height=600, width= 500, status=n o, resizable= no, scrollbars= no, toolbar= no,location= no, menubar= no');");

I am writing this code in Page_Load event.This code works perfectly fine when used in a simple form. But as soon as i added a master page and had written this code in child page it is showing me "Object Reference not set to an instance of an object." error. Can someone please help me to fix it. Thanks in Advance.
  #2 (permalink)  
Old October 30th, 2009, 10:12 AM
Friend of Wrox
Points: 4,332, Level: 27
Points: 4,332, Level: 27 Points: 4,332, Level: 27 Points: 4,332, Level: 27
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2003
Location: , NJ, USA.
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

If the hyperlink is on the form and not in another containing control, then there is no need for the findcontrol(). Now, since you have put this code on a content page, you are getting the error because the form is actually on the masterpage, so, it will not find a form on the content page. So, remove the findcontrol().
 


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
this.attributes.add not working millerthegorilla SharePoint Development 1 June 17th, 2008 03:44 AM
simple wish: to add 'http://' to a HyperLink bananas ASP.NET 2.0 Basics 1 June 21st, 2006 08:41 AM
Calling Javascript Function With Attributes.Add OutCaster ASP.NET 1.0 and 1.1 Basics 1 January 27th, 2006 09:53 PM
Child Page Problem with Handles My.Base Load bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 1 October 4th, 2004 09:30 AM
How to add hyperlink in crystal report when openin Diamond_in_the_sky Crystal Reports 0 March 24th, 2004 01:25 PM



All times are GMT -4. The time now is 05:12 AM.


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