How to access Html table server side

Posted by Jayakumars under Regular Expressions on 5/31/2011 | Points: 10 | Views : 10934 | Status : [Member] [MVP] | Replies : 14
hi

I need how to retrieve Html Table to server side i am try innerhtml i didnot access them how to retrieve html table to server side i need most urgent.

Mark as Answer if its helpful to you


Responses

Posted by: Ndebata on: 6/1/2011 [Member] Starter | Points: 25

Up
0
Down
Hi
First of all try to add runat="server" tag to html element you are trying to access in server side.
In case of table you can access the inner html,
you can access rows then cells, then for each cell you can access the innerHtml property.

Thanks,
Debata

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
thanks Your Reply
Debata i know which control we will access server that control should be runat=server but inner html not support object error comes you can try and reply
them.

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u6178 on: 6/1/2011 [Member] Starter | Points: 25

Up
0
Down
Hi jayakumars,

1.include runat=server attribute to ur table tag.
2.use the following code snippet to create table server side .

Table table=new Table();
TableRow row=new TableRow();
TableCell cell=new TableCell();
cell.Text="your TD value Here";
row.cells.Add(cell);
table.rows.Add(row);
Form1.Control.Add(table);
3.include this namespace:using System.Web.UI.HtmlControls;


Thanks & Regards;
aaa

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 6/1/2011 [Member] Bronze | Points: 25

Up
0
Down
Pls see the example below:

aspx
<body>

<form id="form1" runat="server">
<div>
<table id="tbl1" runat="server">
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
<tr>
<td>four</td>
<td>five</td>
<td>six</td>
</tr>
</table>
</div>
<asp:Label ID="lbl1" runat="server" />
</form>
</body>


aspx.cs
 protected void Page_Load(object sender, EventArgs e)

{
var str= tbl1.Rows[0].Cells[2].InnerHtml;
lbl1.Text = str.ToString();
}


To get all the values in code behind

protected void Page_Load(object sender, EventArgs e)

{
string str;
for (int i = 0; i < tbl1.Rows.Count; i++)
{
for (int j = 0; j < tbl1.Rows[i].Cells.Count; j++)
{
str = tbl1.Rows[i].Cells[j].InnerHtml;
lbl1.Text = lbl1.Text + " " + str;
}
}


}
Thanks,

Nitha Deepak

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

Good Post Nithadeepak thanks
but i need like this can you change this

lbltext.text=" <table id="tbl1" runat="server">
<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
<tr>
<td>four</td>
<td>five</td>
<td>six</td>
</tr>
</table>";

because i will send this html table through the mail so i need this otherwise can you told any idea thanks

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 6/1/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Jayakumar,
In case you are assigning your table like this you have to replace all your " by '
like i changed your example to.
lbltext.Text = @"<table id='tbl1' runat='server'> 

<tr>
<td>one</td>
<td>two</td>
<td>three</td>
</tr>
<tr>
<td>four</td>
<td>five</td>
<td>six</td>
</tr>
</table>";


Thanks,
Debata

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 6/1/2011 [Member] Bronze | Points: 25

Up
0
Down
Hi,

If you wan't to sent an html table through email, try this code....

MailMessage message = new MailMessage();

message.From = new MailAddress("sender@foo.bar.com");
message.To.Add(new MailAddress("recipient3@foo.bar.com"));
message.CC.Add(new MailAddress("carboncopy@foo.bar.com"));
message.Subject = "This is my subject";
message.IsBodyHtml = true;
message.Body = "<table id=\"tbl1\" runat=\"server\"><tr><td>one</td><td>two</td><td>three</td></tr><tr><td>four</td><td>five</td><td>six</td></tr></table>";
SmtpClient client = new SmtpClient();
client.Host ="IP address of the host used for SMTP transactions";
client.Port = 25;
client.Send(message);


Nitha Deepak

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
this code following error comes

Failure sending mail.
"Unable to connect to the remote server

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 6/1/2011 [Member] Bronze | Points: 25

Up
0
Down
Check whether you give the correct IP.
client.Host ="IP address of the host used for SMTP transactions. ";

Thanks,


Nitha Deepak

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Nithadeepak

I am go to url what is my ip from google search box there fetch my ip i am copy that ip include my aspx page this is wrong tell me i need send mail services
i need most urgent.

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 6/1/2011 [Member] Bronze | Points: 25

Up
0
Down
ask to the infrastructure team of your company about the IP address of the host used for SMTP transactions.
Thanks,

Nitha Deepak

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi Jayakumar,

use this link to find out ur IP addres,

http://www.chami.com/tips/internet/041498i.html
http://www.growthhouse.org/ip_address.html

Otherwise check for ur Port number

Regards,
Susan

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 6/1/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi
Susan , Nithadeepak thanks Your Reply
but
i know my system ip i need how to send html table send mail services add i have go daddy account only how to achieve this.

Mark as Answer if its helpful to you

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nithadeepak on: 6/1/2011 [Member] Bronze | Points: 25

Up
0
Down
Its not your system IP address that is needed. You want the 'IP address of the host used for SMTP transactions' to send emails.

Nitha Deepak

Jayakumars, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response