Learn how to a build a cloud-first strategyRegister Now


Get the value of a control from a contentplaceholder

Posted on 2012-09-07
Medium Priority
Last Modified: 2012-09-20
I have this list is my masterpage

      <li><a href="Schoolpage.aspx?tid=">Add a School</a></li>

How would I get the value of tid which is in a ContentPlaceholder ID="Maincontent"
label1.text which i would like to add the code in that line so it would hyperlink to the page
with the value?

How will I refer to that value?
Question by:zachvaldez
LVL 11

Accepted Solution

madgino earned 300 total points
ID: 38379067
use Master.FindControl("Maincontent") to get hold of the placeholder object.
Master.FindControl("Maincontent").FindControl("label1") will give you the label.

If you want to change the link you have to use a hyperlink object instead of "a href" tag
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 195 total points
ID: 38379354
FindControl only works for element with runat="server", and not  client-side HTML elements.
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 23

Assisted Solution

by:Roopesh Reddy
Roopesh Reddy earned 300 total points
ID: 38380909

Yeah! Only Server controls(runat="server") can be accessed using FindControl method!

Try adding runat="server" attribute to the control which you wish to access and try again with FindControl method!

Hope it helps u...

Author Comment

ID: 38383170
what Im trying to do is click that hyperlink in the masterpage and get the value of label1.text from aspx1(this is in the "maincontent" contentplaceholder) and place it in label2.text of aspx2(this is also in the "maincontent" contentplaceholder) of masterpage.

Can you post a code how to get it?  tkns

Author Comment

ID: 38394811
I change the control to LInkbutton and it worked. I just use navigateurl... property and also I was able to querystring the params passed and did an encryption/decryption when passed from page to page. Thanks for your help.
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38395118

Glad you solved your problem!

Author Closing Comment

ID: 38420541
I found a solution other the ones recommended. Thanks for the alternative solutions

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month21 days, 3 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question