Solved

Access Html control in code behind

Posted on 2009-07-10
5
372 Views
Last Modified: 2012-05-07
I usually use all asp control but supporting others code and I need to know how to access a html control in my code behind.  Here is the control name
<DIV id="divAdmin" style="DISPLAY: inline"></DIV>
I put the run at server
<DIV id="divAdmin" style="DISPLAY: inline" runat="server"></DIV>
it shows up in code behind as such
 Protected WithEvents divAdmin As System.Web.UI.HtmlControls.HtmlGenericControl

But when I try to get the text of the control I cannot access it when I do a
Dim Name as string = divAdmin ?????

nothing I choose lets me get the text in there.
0
Comment
Question by:kdeutsch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 1

Expert Comment

by:alpacaman
ID: 24825766
You want to access it in C# ?

If so, check out the panel control.  It works a lot like a div. If you need to add controls, check out the place holder control.  You can add controls to a place holder, a panel is just a way of wrapping the controls.

<asp:panel runat="server" id="mypnl">
<table> </table>
<asp:paenl>

code:
mypanel.Visible = false;

would hide your table.
0
 
LVL 1

Expert Comment

by:alpacaman
ID: 24825779
if you wane specfic text:

<asp:panel>
<asp:label id="usethislabeltogetthetext">some stuff</asp:label>
</asp:panel>
0
 

Author Comment

by:kdeutsch
ID: 24826176
I know I can access asp labels but can I get acces to a div with text that was placed in it.  The way it was coded was with div satements and then the coder put text in it.  I put in runat server but I still cannot seem to get the text out of the control.  It looks like I am going to have to recode and put in an asp label control.
0
 
LVL 1

Accepted Solution

by:
alpacaman earned 200 total points
ID: 24826206
I would just replace the <div> with <asp:panel>

Yeah there really is no way to access a div tag directly.  With the panel you will at least be able to change everything inside panel in one line of code.

You could also use javascript to get the text insde the div, but that would be on the client side.
0
 

Author Closing Comment

by:kdeutsch
ID: 31602067
Well lots of recoding to do now.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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