p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Professional
I forgot my password Register Now
Register | FAQ | Members List | Calendar | 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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 29th, 2009, 01:56 PM
Authorized User
Points: 94, Level: 1
Points: 94, Level: 1 Points: 94, Level: 1 Points: 94, Level: 1
Activity: 5%
Activity: 5% Activity: 5% Activity: 5%
 
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 30th, 2009, 09:47 AM
Imar's Avatar
Wrox Author
Points: 33,563, Level: 80
Points: 33,563, Level: 80 Points: 33,563, Level: 80 Points: 33,563, Level: 80
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 Posts
Default

Hi there,

The reason for this behavior is that with a master page the naming container has changed. You now need to search in a different naming container: the ContentPlaceHolder in the master page. This should work:

HyperLink h1 =(HyperLink)Master.FindControl("ContentPlaceHolder 1").FindControl("hlnkPatienType");

For more details, take a look here: http://west-wind.com/weblog/posts/5127.aspx

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004

Did this post help you? Click the button to show your appreciation!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem in child page with Hyperlink.Attributes.Add nrlahoti ASP.NET 2.0 Professional 1 October 30th, 2009 11:12 AM
this.attributes.add not working millerthegorilla SharePoint Development 1 June 17th, 2008 04:44 AM
simple wish: to add 'http://' to a HyperLink bananas ASP.NET 2.0 Basics 1 June 21st, 2006 09: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 10:30 AM



All times are GMT -4. The time now is 08:28 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc