473,385 Members | 1,757 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,385 software developers and data experts.

How to Access HTML Controls from code behind ?

Hi ,

I have a table which needs to be populated at runtime. Is there a way
to do this without using a server side control like repeater or
datagrid ? How can an HTML control be accessed in code behind ?

Thanks in advance ..

Sep 28 '06 #1
4 8658
Hello vivekian,

how your server may know about client controls?
you need to use either server controls or use XMLHttpRequest to get data
in runtime and fill your client

vHi ,
v>
vI have a table which needs to be populated at runtime. Is there a way
vto do this without using a server side control like repeater or
vdatagrid ? How can an HTML control be accessed in code behind ?
v>
vThanks in advance ..
v>
---
WBR,
Michael Nemtsev :: blog: http://spaces.live.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Sep 28 '06 #2
For most you can just add runat=server and than they go.

By instance the input box or the Iframe.

I hope this helps,

Cor

<vi********@gmail.comschreef in bericht
news:11*********************@i42g2000cwa.googlegro ups.com...
Hi ,

I have a table which needs to be populated at runtime. Is there a way
to do this without using a server side control like repeater or
datagrid ? How can an HTML control be accessed in code behind ?

Thanks in advance ..

Sep 28 '06 #3
Hi

There are two things you have to do.

(1) Edit the HTML code to include the attribute runat="server" in the
opening tag of the HTML control. For example for a table it might be:

<TABLE id="Table1" ...(other attributes) ... runat="server">

(2) Then you need to include the namespace "System.Web.UI.HtmlControls"
in the code behind (e.g. in VB the directive Imports
System.Web.UI.HtmlControls).

If you are using Visual Studio then you will find that it will become
available in auto-complete under the identifier (in the example above)
Table1.

With that you will be able to program it's behaviour in a very similar
manner to web Server controls.

Hope that helps

Phil Hall

Sep 28 '06 #4
Hi

There are two options here.

One is to use a server control of type "Table" i.e.
System.Web.UI.WebControls.Table which you can construct in code by
creating objects of type TableRow and TableCell. To put content in the
cells use the method "Controls.Add(x)" for the TableCell object where x
is any other type of visual control (e.g. a label)

The other way is to add the attribute runat="server" to an HTML table
tag
e.g. <TABLE id="Table1" ... runat="server">.

Also make sure that it has an ID attrubute, i.e. an attribute like
id="Table1". Then include the namespace System.Web.UI.HtmlControls
(e.g. in VB; Imports System.Web.UI.HtmlControls)

Having done that populate the table using the InnerHtml property for
cells, e.g. in VB:

Table1.rows(x).cells(y).InnerHtml = "<p>Hello World</p>"

where x, y are zero referenced integers

Hope that helps

Sep 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: SStory | last post by:
Doing pages for contract..... If I make an ASPX file that does certain things, how simple would it be for a person who know nothing about it to modify the user interface without bothering the...
0
by: bill yeager | last post by:
I have a datalist displaying parent information and a datagrid presenting child information. The data is being rendered just fine. The datagrid has template columns on it that I cannot gain access...
5
by: siaj | last post by:
Hello All, Can any one give me a clue when to use Web Server controls/ HTML server controls/HTML Controls. As I understand .. HTML controls should be used if u dont need to refer it in the code...
2
by: fxs | last post by:
Hello, I have the following controls on an aspx page: 2 html radio button controls, 1 asp:label control and 1 asp:button control.... <INPUT id="rdo1" type="radio" name="grp1"...
2
by: N. Demos | last post by:
I have a user control with code behind of which two instances are created/declared in my aspx page. The aspx page has code behind also, as I need to access methods of the usercontrols on page...
5
by: serge calderara | last post by:
Dear all, I am new in asp.net and prepare myself for exam I still have dificulties to understand the difference between server control and HTML control. Okey things whcih are clear are the fact...
3
by: Mr Newbie | last post by:
I am messing around with Web User Controls at present and (think) I have discovered the following. 1.) The identifier for the control in the code behind must match the ID for the control on the...
5
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
1
by: bradwoody | last post by:
ASP.Net and C# I am having trouble determining how to manipulate html controls via javascript AND access those same controls in the C# code behind. Here's the scoop: I am making an advanced...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.