By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,289 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,289 IT Pros & Developers. It's quick & easy.

problem of changing values for tableCell element

P: n/a
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
Share this Question
Share on Google+
6 Replies


P: n/a
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

P: n/a

"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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.