473,385 Members | 1,798 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.

problem of changing values for tableCell element

Hello,
I have the following aspx code :

<form id = "main_form" runat = "server">

<asp:Table dir = "rtl" runat = "server">
<asp:TableRow>
<asp:TableCell id = "inner_message">&nbsp;</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
How can I change the contents of the value of TableCell in the server side
script ?

(What should I write in the following :
<script runat="server">
...
inner_message.innerHtml = "some message" ' doesn't work - what
should I put instead.
</script>
)

Thanks :)
Nov 18 '05 #1
6 1681
In your code, the runat=server is missing. may that help ???

"Mr. x" <a@b.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello,
I have the following aspx code :

<form id = "main_form" runat = "server">

<asp:Table dir = "rtl" runat = "server">
<asp:TableRow>
<asp:TableCell id = "inner_message">&nbsp;</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
How can I change the contents of the value of TableCell in the server side
script ?

(What should I write in the following :
<script runat="server">
...
inner_message.innerHtml = "some message" ' doesn't work - what
should I put instead.
</script>
)

Thanks :)

Nov 18 '05 #2

"Patrick Dahmen" <p.******@e-llusions.de> wrote in message
In your code, the runat=server is missing. may that help ???


Well,
that's what I did - as you see at my code,
so I don't understand what's wrong.
Also, I can access inner_message (so it's not seems as runat=server
mistake).
The question is how can I change it, please.

Thanks :)
Nov 18 '05 #3
Mr. x wrote:
(What should I write in the following :
<script runat="server">
...
inner_message.innerHtml = "some message" ' doesn't work - what
should I put instead.
</script>


What do you mean with "doesn't work" ?
Do you get an error message and if so, what's the error ?

Does it work if you access the cell by doing it like
table.Rows[0].Cells[0].InnerHtml = "some message" ?

Regards,

Eric

Nov 18 '05 #4
If you need to look for the tablecell according to its ID, here's a way that
will do it. It is much more efficient if you can just reference it by index
(such as tblrow.Cells(0) )

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim tblrow As TableRow
Dim tblcell As TableCell
Table1.GridLines = GridLines.Both
tblrow = Table1.Rows(0)
tblcell = tblrow.Cells _
(tblrow.Controls.IndexOf _
(tblrow.FindControl _
("inner_message")))
tblcell.Text = "Mr. X should use a friendlier name."
End Sub

"Mr. x" <a@b.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Hello,
I have the following aspx code :

<form id = "main_form" runat = "server">

<asp:Table dir = "rtl" runat = "server">
<asp:TableRow>
<asp:TableCell id = "inner_message">&nbsp;</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
How can I change the contents of the value of TableCell in the server side
script ?

(What should I write in the following :
<script runat="server">
...
inner_message.innerHtml = "some message" ' doesn't work - what
should I put instead.
</script>
)

Thanks :)

Nov 18 '05 #5
Ken Cox wrote :
If you need to look for the tablecell according to its ID, here's a way that will do it. It is much more efficient if you can just reference it by index (such as tblrow.Cells(0) )

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim tblrow As TableRow
Dim tblcell As TableCell
Table1.GridLines = GridLines.Both
tblrow = Table1.Rows(0)
tblcell = tblrow.Cells _
(tblrow.Controls.IndexOf _
(tblrow.FindControl _
("inner_message")))
tblcell.Text = "Mr. X should use a friendlier name."
End Sub I have checked this out.
It may be a tinny mistake, but I get the message :
System.ArgumentOutOfRangeException: Specified argument was out of the range
of valid values. Parameter name: index

I suppose tblrow.FindControl("inner_message") returns null, or -1,
but there is something in the code which is wrong, which I cannot figure
out.
tblcell.Text = "Mr. X should use a friendlier name."


O.K, I'm Eitan (and from now on, I'll keep using my original name, althogh I
hate spams - I have 2 years my account in the same ISP, and I don't get even
one single spam ... For only the name - it's fine with me, but beleive me I
am getting more response then I used to before I used Mr.X's name).

Thanks :)
Nov 18 '05 #6
Hi Eitan,

Strange, 'cause it works for me in ASP.NET 1.1 . Here's the complete code in
case that helps:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="tbl.aspx.vb"
Inherits="p4320work.tbl"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>tbl</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="main_form" runat="server">
<asp:Table dir="rtl" runat="server" ID="Table1" NAME="Table1">
<asp:TableRow>
<asp:TableCell id="inner_message">&nbsp;</asp:TableCell>
</asp:TableRow>
</asp:Table>
</form>
</body>
</HTML>

''''''''

Public Class tbl
Inherits System.Web.UI.Page

#Region " Web Form Designer Generated Code "

'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()

End Sub
Protected WithEvents Table1 As System.Web.UI.WebControls.Table

'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub

#End Region

Private Sub Page_Load _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim tblrow As TableRow
Dim tblcell As TableCell
Table1.GridLines = GridLines.Both
tblrow = Table1.Rows(0)
tblcell = tblrow.Cells _
(tblrow.Controls.IndexOf _
(tblrow.FindControl _
("inner_message")))
tblcell.Text = "Hi Eitan!."
End Sub

End Class
Nov 18 '05 #7

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

Similar topics

0
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These...
2
by: patrick_a | last post by:
Hi, I'm having trouble with using !IsPostBack. I want to create a linkbutton within a table when the page loads the first time and then have the page redirect based on the...
0
by: Scott P. | last post by:
I'm creating an app using ASP .NET (my second app so bear with me here) that basically builds a PDF file based on a bunch of user selections. I have a page which displays a series of checkboxs...
0
by: Diane Yocom | last post by:
I'm very new to ASP.Net and probably jumped in a little over my head, but... I'm trying to create a user control that will control navigation through my site. It's sortof like Amazon.com, where...
0
by: fernandezr | last post by:
Hi, I've got a user control that is referenced twice on the same page and I'd like to access the textbox values on postback so I can update a database. How can get the values for each instance of...
7
by: Matt Kruse | last post by:
Using the .cellIndex property of a TH element to find out which table column it is over can cause misleading results when the table has cells which have rowspans or colspans greater than 1. See...
1
by: Jeff | last post by:
hey asp.net 2.0 I'm trying to create a web page where users can register to my web portal. But I've run into a layout problem when using the data validator classes. The problem is that the...
5
by: Slim | last post by:
i have a simple page, with one button button1. when click it creates a new button button 2 and adds a event handler to it. but when button 2 is clicked nothing happens, why? Partial Class...
3
by: amjad905 | last post by:
Hi, I have created some dynamic labels and some dynamic linkbuttons... those linkbuttons have addhandlers assigned to them... but in postback those buttons gets deleted... the code is shown...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
Oralloy
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,...
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.