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

October 29th, 2009, 01:56 PM
|
|
Authorized User
|
|
Join Date: Oct 2007
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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.
|

October 30th, 2009, 09:47 AM
|
 |
Wrox Author
Points: 33,563, Level: 80 |
|
|
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,231
Thanks: 7
Thanked 203 Times in 201 Posts
|
|
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
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |