Hi all,
I'm trying to write a simple page where a table's properties and contained
controls are generated dynamically.
I have the following code:
In Test.aspx:
<%@ Page language="c#" Codebehind="Tes t.aspx.cs" AutoEventWireup ="false"
Inherits="Test. TestForm" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Test</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="C#" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body MS_POSITIONING= "GridLayout ">
<form id="TestForm" method="post" runat="server">
<table id="TestTable" runat="server">
</table>
</form>
</body>
</HTML>
In test.aspx.cs:
public class TestForm : System.Web.UI.P age
{
private void Page_Load(objec t sender, System.EventArg s e)
{
// Put user code to initialize the page here
TestTable = new HtmlTable();
TestTable.Width = "100%";
HtmlTableRow rw = new HtmlTableRow();
HtmlTableCell cl = new HtmlTableCell() ;
cl.InnerText = "Test";
rw.Cells.Add(cl );
TestTable.Rows. Add(rw);
}
#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.Load += new System.EventHan dler(this.Page_ Load);
}
#endregion
protected System.Web.UI.H tmlControls.Htm lTable TestTable;
}
Like I said, very simple.
However, when I run the code, nothing shows up - I would expect to see a
single cell with 'Test' displayed in it.
Can anyone explain what's going on here?
TIA,
--
Akin
aknak at aksoto dot idps dot co dot uk 1 1353
You're creating a new HTML Table, that could be causing the problem. The
Table already exists that's part of the form so just create a local
protected variable for the page class like so:
protected HtmlTable TestTable;
If this is being generated by VS.Net, it should already be creating a
protected variable for you. Then all you do is add the row to the table just
like you already do and it should be good. When you set the TestTable = new
HtmlTable() in code behind you're now pointing TestTable to a different
object, meaning it isn't referencing the one in the form anymore.
Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
"Epetruk" <no****@blackho le.com> wrote in message
news:37******** *****@individua l.net... Hi all,
I'm trying to write a simple page where a table's properties and contained controls are generated dynamically.
I have the following code: In Test.aspx:
<%@ Page language="c#" Codebehind="Tes t.aspx.cs" AutoEventWireup ="false" Inherits="Test. TestForm" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD> <title>Test</title> <meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR "> <meta content="C#" name="CODE_LANG UAGE"> <meta content="JavaSc ript" name="vs_defaul tClientScript"> <meta content="http://schemas.microso ft.com/intellisense/ie5" name="vs_target Schema"> </HEAD> <body MS_POSITIONING= "GridLayout "> <form id="TestForm" method="post" runat="server"> <table id="TestTable" runat="server"> </table> </form> </body> </HTML> In test.aspx.cs:
public class TestForm : System.Web.UI.P age { private void Page_Load(objec t sender, System.EventArg s e) { // Put user code to initialize the page here TestTable = new HtmlTable(); TestTable.Width = "100%"; HtmlTableRow rw = new HtmlTableRow(); HtmlTableCell cl = new HtmlTableCell() ; cl.InnerText = "Test"; rw.Cells.Add(cl ); TestTable.Rows. Add(rw); }
#region Web Form Designer generated code override protected void OnInit(EventArg s e) { // // CODEGEN: This call is required by the ASP.NET Web Form Designer. // InitializeCompo nent(); base.OnInit(e); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeCompo nent() { this.Load += new System.EventHan dler(this.Page_ Load); } #endregion
protected System.Web.UI.H tmlControls.Htm lTable TestTable; } Like I said, very simple.
However, when I run the code, nothing shows up - I would expect to see a single cell with 'Test' displayed in it.
Can anyone explain what's going on here?
TIA, -- Akin
aknak at aksoto dot idps dot co dot uk
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bajal Mohamed via SQLMonster.com |
last post by:
I am facing problem like;
We generate reports thru Excel Pivot table. The data is coming from sales
cube. Let?s assume that there are 2 products A and B. The user wants to
filter for each product and view ?stock in hand? and ?total sales? for
particular month (as two columns).
From the Pivot table filtering, when we choose product A and month ?Jan?,
it is showing values for ?stock in hand? and ?total sales? columns for that
month.
|
by: db2group88 |
last post by:
hi, we install db2 udb v8.1 on windows 64bit, in our application, we
have sql execute "create table .... not logged initially", but from
the operating system event viewer showing error stating that ADM5530E
The COMMIT processing of table "TBSPACEID=3.TABLEID=15107" that used
NOT LOGGED INITIALLY has been initiated. It is recommended that you
take a
backup of this table's table space(s).
since our application need to create table on the...
|
by: Emily Jones |
last post by:
That subject line will have Joe Celko apoplectic!!
Let's say I have this thing. Oh, I don't know, a car. No, a vehicle. Can we
agree that is an entity type?
Some attributes might be VIN, Fuel, Color.
Some entity instances might be:
wvv2939-32-2993-2-90, Gasoline, Blue
wvv3942-3249--2830-2, Diesel, Red
I wanna make it easy to get the colors in. Keep a list of 'em somewhere. So
|
by: Raed Sawalha |
last post by:
I have the following table in ascx , when I click the button the table style
not showing in the popup , it is ONLY showing on the page not in the
popup...WHY?
<TABLE style="BACKGROUND: #d8e8f5;CURSOR:hand" bgcolor="#d8e8f5"
id="tblMenu" cellSpacing="0" cellPadding="2" width="150" border="1">
<TR>
<TD class="standerdfont" >New Document</TD>
</TR>
<TR>
|
by: ezmiller |
last post by:
Hi,
I have some code (which I will paste in below) that writes out some
HTML dynamically using the W3C DOM...the last part of the code write
out a simple table. MY problem is that the table is not showing up,
even though it seems to be part of the document (i.e. I can reach the
nodes through through document.body.getElementsByTagName... )
var e;
var f; // Will hold a document fragment.
| |
by: Rahul |
last post by:
Hi,
I tried many option, but did not found solution. Same Validation Error
showing. If I have convert one table, it can easily converted. But If I
have paste another table in same file, then showing validation Error.
This Error is --
=======================================================
|
by: john |
last post by:
In my form I have a master table and a details table linked 1xM. I can
search through the whole parent table but I also like to be able to search
through the child table fields to find parent records. Should I design a new
form for this or can I somehow make this work in the same form.
Thanks in advance,
john
|
by: spacix |
last post by:
Does anyone know a work around for "table-layout: fixed;" to prevent the automatic evenly space cells width without assigning classes or ID to cells?
My program prints a HTML "report" file and I used "table-layout: fixed; width:691px;" because the reports have to be printed on 8.5x11 paper. I didn't want the table to resize or anything.
Then after I added that property to the table, the data cells no longer "fit to contents" even with a...
|
by: sitko |
last post by:
Hi,
I'm done a little HTML here and there over the years...but nothing professionally. Now I'm working on a project which calls for some simple HTML. Here is my markup, for the life of me I can't figure out why the chart borders aren't showing up.
<html><body>
<table border=”1”>
<tr>
<td>Measurement locations</td><td>Description</td><td>elapsed time, </td><td>Data: Dock A (AFF) </td><td>Model: min. T_mix</td><td>Model: ...
|
by: reelrave |
last post by:
Hello All,
I've checked around a little on Google (and this group) and have found
info similar to what I'm trying to do (i.e., changes that were made in
the BE's tables are not reflected in the FE database) and have heard
suggestions using code, etcetera. But I need a bit more clarification
please.
What I'm doing/have done is this (MS Access 2007, FE stored on WXP
clients, BE stored on a W2K3 server):
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |