473,327 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Problem in accessing contentplaceholder element

Hi
I am using a master page in which I have only one contentplaceholder and inside this contentplaceholder I added a label.
The problem is when I tried to assign some value to this label from codebehind of the master page itself it gives "Object reference not set to an instance of an object." error. I tried all my actions from page_load event and ContentPlaceHolder1_Load event with contentplacholder1.findcontrol("lbl1") and simply lab1.text=<value>. But problem could not solved. It look realy simple but I am confused.

Please Any body help me.
L. Premchandra khaba

My works:

1. My.master
......
......
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
<asp:Label ID="lbl1" runat="server" ></asp:Label>
</asp:ContentPlaceHolder>
.....
....

2.My.master.vb
Protected Sub Page_Load(o As Object, e As EventArgs)
Dim lbl123 As Label = CType(ContentPlaceHolder1.FindControl("lbl1"), Label)
lbl123.text="Hi" Or Simply lab1.text="Hi"
end sub

Same thing with ContentPlaceHolder1_Load event
Jun 2 '07 #1
2 1515
kenobewan
4,871 Expert 4TB
Have you tried using the full path for the label?
Jun 2 '07 #2
nmsreddi
366 256MB
Hello

I think that content place holder on master page is placed for use in content pages that uses the master page ,

why you are placing controls in content place holder ,you can place them out side the placeholder ,which you can acces from any content page ,

i hope you got the point
Jun 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Support | last post by:
Hello: I have a master page that contains a table with three rows <table height="100%" width="100%"> <tr><td height="100"><td>header</td></tr> <tr><td height="100%"><asp:contentplaceholder...
0
by: Adam Tibi | last post by:
Hello, I have this: MasterPage 1: <asp:ContentPlaceHolder ID="cphHead" runat="server"> </asp:ContentPlaceHolder> Some Html... <asp:ContentPlaceHolder ID="cphBody1" runat="server">...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
0
by: nickster | last post by:
For some reason when I use asp controls for the default content of a ContentPlaceHolder, they do not get rendered. Static content is rendered just fine however! Specifically I'm using multiple...
3
by: vespaboy | last post by:
i need to access a <div runat="server"which sits in a master page which is itself nested in a master page. i've tried this code but it doesn't work: Page: Dim divStep1 As HtmlGenericControl =...
0
by: Anilsg | last post by:
Hi, I have to add the Updatepanel to the Master page in which the DefultContenPanel have to be in it, base on some condition . If the condition is flase then the UpdatePanel should not...
4
by: morad.87 | last post by:
This code works properly in IE ,but fire fox doesn't show the image!! <%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %> <!DOCTYPE...
5
by: xlar54 | last post by:
I have a very simple 2.0 website (framework), that uses a master page...not. I added the default.aspx page as a webcontent form, with the master page as it's master page, but the master page is...
0
by: Andy B | last post by:
I have a div on the master page that is 600px high. It has a left pannel, main content (contentPlaceHolder) inside another div and a footer. What I am looking for is a few things: 1. How do you...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.