Showing posts with label visual. Show all posts
Showing posts with label visual. Show all posts

Wednesday, March 28, 2012

TableLayoutPanel Control

Hi!

I am trying to create an Excel-like table in Visual Basic 2005 / Visual C# 2005 EE.

I use TableLayoutPanel control to present the data.

However, I found out that this table layout is not very efficient, like: I can't draw the border for specific cell, nor can I resize one cell to be bigger than others.

Is there a way to do this? Or maybe there is a better way to create an Excel-like table?

Many thanks in advanced!!!!

Hi,

Is this a web control??


Actually, I use Visual Basic 2005 EE for Windows Form. I don't know if VWD 2005 EE has the same control or not.

I am trying to build an application that run in Windows OS. The application will need this Excel-like table layout.

Thanks for you help and time, really appreciated that.


Can somebody help me please?

Many thanks in advanced!

Tables

Newbie here.

I'm hasving trouble with tables in Visual Web Developer Express.

I've set cellspacing and cellpadding to zero, but there's spaces around
objects in my table.

Any idea what's going wrong?Hi

Check whether you have assigned some width for every table cell (<td>),
which is giving you this experience. Try to set the width as zero and see how
it appears.

Prem
Newbie here.

Quote:

Originally Posted by

>
I'm hasving trouble with tables in Visual Web Developer Express.
>
I've set cellspacing and cellpadding to zero, but there's spaces around
objects in my table.
>
Any idea what's going wrong?


Where do you see those spaces? In the designer or in the resulting
webpage in the browser?
The designer might show spaces (and borders) to make the layout clear.
If in the browser, check the resulting html code ("view source") to see
if you can find a reason for those spaces there.

Hans Kesting

tables ;-(

Hello,

I am trying to stop some behavior going on with a table. I have been
using Visual Studio C# 2005.

Basically, the table has certain column widths to start out with. When
data is added to it (and the size of the column is too small), the data
(in this case text) in the column wraps ;-/

How can I keep the data from wrapping? What would be nice is if no
wrapping to place at all and to just be able to adjust the size of
columns manually. You know - where you place the cursor on the boundary
of the column, the cursor changes and then you can lengthen or shorten
the width of the column in order to see more (or less) data.

So, in a nutshell, I would like for the column widths (as well as the
table length and width) to remain the same size as did from the start.
Adjustment of column widths would take place only when using the mouse
;-)

How can I do this?

TIAIm guessing here, but if you think about what the system would need to do in
order to assess the column width Its unlikely that it is going to do it for
you.

In order to assess the column with of any column, one would have to loop
through each cell and get the context, font and size and then measure this
graphically; For each iteration, one would need to adjust the column width
for each lager than previous cell until the end were reached.

If there is no automatic way of doing this then you would have to do this
manually with code.

Other comments ?

Mr N.

"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
Try style rule table-layout:fixed;

Eliyahu

"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
milkyway wrote:
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the
> data (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the
> boundary of the column, the cursor changes and then you can lengthen
> or shorten the width of the column in order to see more (or less)
> data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA

Watch out for a too-exact layout, one that is "perfect" on your development machine.
A user might use a different browser, have different installed fonts or uses
by default a font with a different size -> gone is your careful layout!

Hans Kesting
set absolute width and overflow style for each td's content, so it can honor
the width. you would need to write client code to resize the table column
widths (adjust the content widths).

<table border=1>
<tr>
<td nowrap><div style="width:40;overflow:hidden">this fits</div></td>
<td nowrap><div style="width:40;overflow:hidden">this xxxxxxxxxxxxxxxxx
doesn't fit</div></td>
</tr>
</table
-- bruce (sqlwork.com)

"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
Thanks to all for the responses ;-)

Bruce Barker wrote:
> set absolute width and overflow style for each td's content, so it can honor
> the width. you would need to write client code to resize the table column
> widths (adjust the content widths).
How would one approach the writing of clinet code to support the
widths? Is there any sample code available?

> "milkyway" <d0mufasa@.hotmail.com> wrote in message
> news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
> > Hello,
> > I am trying to stop some behavior going on with a table. I have been
> > using Visual Studio C# 2005.
> > Basically, the table has certain column widths to start out with. When
> > data is added to it (and the size of the column is too small), the data
> > (in this case text) in the column wraps ;-/
> > How can I keep the data from wrapping? What would be nice is if no
> > wrapping to place at all and to just be able to adjust the size of
> > columns manually. You know - where you place the cursor on the boundary
> > of the column, the cursor changes and then you can lengthen or shorten
> > the width of the column in order to see more (or less) data.
> > So, in a nutshell, I would like for the column widths (as well as the
> > table length and width) to remain the same size as did from the start.
> > Adjustment of column widths would take place only when using the mouse
> > ;-)
> > How can I do this?
> > TIA
You could easily ammend this code to suit your table control.

http://www.trainingon.net/Articles/TIP0005.htm

HTH

"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127968780.006696.275920@.g43g2000cwa.googlegr oups.com...
> Thanks to all for the responses ;-)
> Bruce Barker wrote:
>> set absolute width and overflow style for each td's content, so it can
>> honor
>> the width. you would need to write client code to resize the table column
>> widths (adjust the content widths).
>>
> How would one approach the writing of clinet code to support the
> widths? Is there any sample code available?
>
>> "milkyway" <d0mufasa@.hotmail.com> wrote in message
>> news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
>> > Hello,
>>> > I am trying to stop some behavior going on with a table. I have been
>> > using Visual Studio C# 2005.
>>> > Basically, the table has certain column widths to start out with. When
>> > data is added to it (and the size of the column is too small), the data
>> > (in this case text) in the column wraps ;-/
>>> > How can I keep the data from wrapping? What would be nice is if no
>> > wrapping to place at all and to just be able to adjust the size of
>> > columns manually. You know - where you place the cursor on the boundary
>> > of the column, the cursor changes and then you can lengthen or shorten
>> > the width of the column in order to see more (or less) data.
>>> > So, in a nutshell, I would like for the column widths (as well as the
>> > table length and width) to remain the same size as did from the start.
>> > Adjustment of column widths would take place only when using the mouse
>> > ;-)
>>> > How can I do this?
>>> > TIA
>
Thanks again - will try it out
Thanks again - will try it out
Put <nobr>text here</nobr> around your text.

Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available

"Mr Newbie" <here@.now.com> wrote in message
news:e1qRrI0wFHA.664@.tk2msftngp13.phx.gbl...
> Im guessing here, but if you think about what the system would need to do
> in order to assess the column width Its unlikely that it is going to do it
> for you.
> In order to assess the column with of any column, one would have to loop
> through each cell and get the context, font and size and then measure this
> graphically; For each iteration, one would need to adjust the column width
> for each lager than previous cell until the end were reached.
> If there is no automatic way of doing this then you would have to do this
> manually with code.
> Other comments ?
> Mr N.
>
> "milkyway" <d0mufasa@.hotmail.com> wrote in message
> news:1127803098.346775.281760@.z14g2000cwz.googlegr oups.com...
>> Hello,
>>
>> I am trying to stop some behavior going on with a table. I have been
>> using Visual Studio C# 2005.
>>
>> Basically, the table has certain column widths to start out with. When
>> data is added to it (and the size of the column is too small), the data
>> (in this case text) in the column wraps ;-/
>>
>> How can I keep the data from wrapping? What would be nice is if no
>> wrapping to place at all and to just be able to adjust the size of
>> columns manually. You know - where you place the cursor on the boundary
>> of the column, the cursor changes and then you can lengthen or shorten
>> the width of the column in order to see more (or less) data.
>>
>> So, in a nutshell, I would like for the column widths (as well as the
>> table length and width) to remain the same size as did from the start.
>> Adjustment of column widths would take place only when using the mouse
>> ;-)
>>
>> How can I do this?
>>
>> TIA
>>

tables ;-(

Hello,
I am trying to stop some behavior going on with a table. I have been
using Visual Studio C# 2005.
Basically, the table has certain column widths to start out with. When
data is added to it (and the size of the column is too small), the data
(in this case text) in the column wraps ;-/
How can I keep the data from wrapping? What would be nice is if no
wrapping to place at all and to just be able to adjust the size of
columns manually. You know - where you place the cursor on the boundary
of the column, the cursor changes and then you can lengthen or shorten
the width of the column in order to see more (or less) data.
So, in a nutshell, I would like for the column widths (as well as the
table length and width) to remain the same size as did from the start.
Adjustment of column widths would take place only when using the mouse
;-)
How can I do this?
TIAIm guessing here, but if you think about what the system would need to do in
order to assess the column width Its unlikely that it is going to do it for
you.
In order to assess the column with of any column, one would have to loop
through each cell and get the context, font and size and then measure this
graphically; For each iteration, one would need to adjust the column width
for each lager than previous cell until the end were reached.
If there is no automatic way of doing this then you would have to do this
manually with code.
Other comments ?
Mr N.
"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegroups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
>
Try style rule table-layout:fixed;
Eliyahu
"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegroups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
>
milkyway wrote:
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the
> data (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the
> boundary of the column, the cursor changes and then you can lengthen
> or shorten the width of the column in order to see more (or less)
> data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
Watch out for a too-exact layout, one that is "perfect" on your development
machine.
A user might use a different browser, have different installed fonts or uses
by default a font with a different size -> gone is your careful layout!
Hans Kesting
set absolute width and overflow style for each td's content, so it can honor
the width. you would need to write client code to resize the table column
widths (adjust the content widths).
<table border=1>
<tr>
<td nowrap><div style="width:40;overflow:hidden">this fits</div></td>
<td nowrap><div style="width:40;overflow:hidden">this xxxxxxxxxxxxxxxxx
doesn't fit</div></td>
</tr>
</table>
-- bruce (sqlwork.com)
"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127803098.346775.281760@.z14g2000cwz.googlegroups.com...
> Hello,
> I am trying to stop some behavior going on with a table. I have been
> using Visual Studio C# 2005.
> Basically, the table has certain column widths to start out with. When
> data is added to it (and the size of the column is too small), the data
> (in this case text) in the column wraps ;-/
> How can I keep the data from wrapping? What would be nice is if no
> wrapping to place at all and to just be able to adjust the size of
> columns manually. You know - where you place the cursor on the boundary
> of the column, the cursor changes and then you can lengthen or shorten
> the width of the column in order to see more (or less) data.
> So, in a nutshell, I would like for the column widths (as well as the
> table length and width) to remain the same size as did from the start.
> Adjustment of column widths would take place only when using the mouse
> ;-)
> How can I do this?
> TIA
>
Thanks to all for the responses ;-)
Bruce Barker wrote:
> set absolute width and overflow style for each td's content, so it can hon
or
> the width. you would need to write client code to resize the table column
> widths (adjust the content widths).
>
How would one approach the writing of clinet code to support the
widths? Is there any sample code available?
> "milkyway" <d0mufasa@.hotmail.com> wrote in message
> news:1127803098.346775.281760@.z14g2000cwz.googlegroups.com...
You could easily ammend this code to suit your table control.
http://www.trainingon.net/Articles/TIP0005.htm
HTH
"milkyway" <d0mufasa@.hotmail.com> wrote in message
news:1127968780.006696.275920@.g43g2000cwa.googlegroups.com...
> Thanks to all for the responses ;-)
> Bruce Barker wrote:
> How would one approach the writing of clinet code to support the
> widths? Is there any sample code available?
>
>
Thanks again - will try it out
Thanks again - will try it out
Put <nobr>text here</nobr> around your text.
Best regards,
Dave Colliver.
http://www.AshfieldFOCUS.com
~~
http://www.FOCUSPortals.com - Local franchises available
"Mr Newbie" <here@.now.com> wrote in message
news:e1qRrI0wFHA.664@.tk2msftngp13.phx.gbl...
> Im guessing here, but if you think about what the system would need to do
> in order to assess the column width Its unlikely that it is going to do it
> for you.
> In order to assess the column with of any column, one would have to loop
> through each cell and get the context, font and size and then measure this
> graphically; For each iteration, one would need to adjust the column width
> for each lager than previous cell until the end were reached.
> If there is no automatic way of doing this then you would have to do this
> manually with code.
> Other comments ?
> Mr N.
>
> "milkyway" <d0mufasa@.hotmail.com> wrote in message
> news:1127803098.346775.281760@.z14g2000cwz.googlegroups.com...
>

Monday, March 26, 2012

Tables arent sized correctly in VS2005

Im using visual studio to make my website, but im having problems with tables every time.

I use the mnouse to resize the tables cells, but every time they are shown totally wrong! If i place a table with to columns and a width of 800px and then set the left coulm to be 50 px then the shown lengt is a third of the table of that column. Also in the preview.

I havent seen this problem in dreamweaver, so i dont know if this is a setting or something that i have to set..

what does the STYLE property look like on the <table> tag?

Are any CSS classes being inherited?


Well it seems like that if i drag a cell in a table, only the width of this cell is being set and not the one in the next cell. Which means that when i get these strange sizes, then the table have the width 800px, but the first column have a width of 50px and the next have the width 150 (just and example). If i then type the proper lenghts in to the style field, then i can make it display properly.

Is this a bug in VS perhaps (a rather big bug i would say)

I would like the drag the sizes around, so that it is easier to see


not sure I follow... but remember that CSS goes down to the lowest level. If you have two colums and you set cell1 to 50 and cell2 to 50 then you get 100... if you want the table to 800 and only cell1 to 50 then make sure that cell2 has NO WIDTH SET...

I've found that NO designer is great for HTML. You are almost always better off doing it yourself from the html view.

tables in asp.net

I am using Visual Microsoft Web developer express. I am using tables to control layouts, and I have hard time controlling tables. In the design view, the layout looks perfect, but actual display of the layout on a browser is horrendous. Design view and actual view are different.

Yup. You'll also find that different browsers will display differently as well. You can live with it, control the layout precisely with specific width and height attributes as well as font sizing and hope it works in most browser, or work with CSS instead of tables. But it's the nature of the environment, you don't control what the user sees, the user and the user's browser does.

Jeff


i would have loved the older way. ie coding it and not using the design way. so that u get a better control of where you want to put the control

Tables troublessss

Hello all
I work with Visual Studio 2005 VB code.
My problem is when I insert a table into another table. It exist a space
between the table and the cells that contains this table.
I tried with ASP and HTML tables and the same occurs.
I also verified that CellSpacing=0 and Cellpadding=0 also I verified the no
presence of <pand <brtags in HTML code.

Someone can help me please?
Thanks.Carlos A. napisa(a):

Quote:

Originally Posted by

Hello all
I work with Visual Studio 2005 VB code.
My problem is when I insert a table into another table. It exist a space
between the table and the cells that contains this table.
I tried with ASP and HTML tables and the same occurs.
I also verified that CellSpacing=0 and Cellpadding=0 also I verified the no
presence of <pand <brtags in HTML code.
>
Someone can help me please?
Thanks.
>
>


Try to set margins to 0 for nested table element (in CSS).

table table{
margin:0;
}

--
PP
Thanks I'll try
"Przemek Ptasznik" <pptaszni@.mila.wywal.to.edu.pllwrote in message
news:ecfik5$7g2$1@.inews.gazeta.pl...

Quote:

Originally Posted by

Carlos A. napisa(a):

Quote:

Originally Posted by

>Hello all
>I work with Visual Studio 2005 VB code.
>My problem is when I insert a table into another table. It exist a space
>between the table and the cells that contains this table.
>I tried with ASP and HTML tables and the same occurs.
>I also verified that CellSpacing=0 and Cellpadding=0 also I verified the
>no presence of <pand <brtags in HTML code.
>>
>Someone can help me please?
>Thanks.
>>
>>


>
Try to set margins to 0 for nested table element (in CSS).
>
>
table table{
margin:0;
}
>
--
PP

Saturday, March 24, 2012

Tabstrip shows only text

I've downloaded IE Web Controls for ASP.NET
I'm using Visual Studio.NET and I included the tabstrip
inside a custom user control.
In the visual studio editor the tab strip appears correctly
but when running on IE it shows only the text labels.!!!!!!!!
I've placed the dll in the bin directory and the webctrl_client
in the same path with the custom control.Well I must add that it works correctly in Mozilla Firefox!!!!
In IE nothing!
I just thought the control was developed from Microsoft OR NOT ? :)
"Stelios Skiathitis" <sski@.keta-notioaigaio.gr> wrote in message
news:d4l852$s47$1@.usenet.otenet.gr...
> I've downloaded IE Web Controls for ASP.NET
> I'm using Visual Studio.NET and I included the tabstrip
> inside a custom user control.
> In the visual studio editor the tab strip appears correctly
> but when running on IE it shows only the text labels.!!!!!!!!
> I've placed the dll in the bin directory and the webctrl_client
> in the same path with the custom control.
>
>
Stelios:
Any chance you have javascript disabled in IE? Perhaps you are using
IE on server 2003 in a hardened security configuration?
Scott
http://www.OdeToCode.com/blogs/scott/
On Tue, 26 Apr 2005 14:22:44 +0300, "Stelios Skiathitis"
<sski@.keta-notioaigaio.gr> wrote:

>I've downloaded IE Web Controls for ASP.NET
>I'm using Visual Studio.NET and I included the tabstrip
>inside a custom user control.
>In the visual studio editor the tab strip appears correctly
>but when running on IE it shows only the text labels.!!!!!!!!
>I've placed the dll in the bin directory and the webctrl_client
>in the same path with the custom control.
>

Tabstrip shows only text

I've downloaded IE Web Controls for ASP.NET

I'm using Visual Studio.NET and I included the tabstrip
inside a custom user control.
In the visual studio editor the tab strip appears correctly
but when running on IE it shows only the text labels.!!!!!!!!

I've placed the dll in the bin directory and the webctrl_client
in the same path with the custom control.Well I must add that it works correctly in Mozilla Firefox!!!!
In IE nothing!
I just thought the control was developed from Microsoft OR NOT ? :)

"Stelios Skiathitis" <sski@.keta-notioaigaio.gr> wrote in message
news:d4l852$s47$1@.usenet.otenet.gr...
> I've downloaded IE Web Controls for ASP.NET
> I'm using Visual Studio.NET and I included the tabstrip
> inside a custom user control.
> In the visual studio editor the tab strip appears correctly
> but when running on IE it shows only the text labels.!!!!!!!!
> I've placed the dll in the bin directory and the webctrl_client
> in the same path with the custom control.
Stelios:

Any chance you have javascript disabled in IE? Perhaps you are using
IE on server 2003 in a hardened security configuration?

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 26 Apr 2005 14:22:44 +0300, "Stelios Skiathitis"
<sski@.keta-notioaigaio.gr> wrote:

>I've downloaded IE Web Controls for ASP.NET
>I'm using Visual Studio.NET and I included the tabstrip
>inside a custom user control.
>In the visual studio editor the tab strip appears correctly
>but when running on IE it shows only the text labels.!!!!!!!!
>I've placed the dll in the bin directory and the webctrl_client
>in the same path with the custom control.

Tuesday, March 13, 2012

TCP Connection

"Hello world",

i'm a visual c# developer but i'm new to ASP.NET.

My question is this one:

it is possibile to make a TCP connection (opening socket e.g.) from my client application to a my web application asp.net? If so, could you suggest how i can start?

Thank you for any suggestion.

Regards,

Lewix

Yes, you could. You can use the System.Net.Sockets namespace. This contains thatTcpClient object and theTcpListener class. Your Web Application will be the listener in this case, and your client will connect to it using the TcpClient class. However, a much more common means of a client communicating with a Web Application is by the means of SOAPWeb Services.


Thank you for your fast reply! :)

last 2 question, then i hope i don't disturb you again:

- the client have to connect to (for example) "www.mydomain.com/listen.aspx:80" ?

- in the asp code i have to handle a "on http request" event and then i start accepting socket?

Sorry for these strange question but with desktop programming is simpler for me :) for now

Thank you for any suggestion

Lewix


Watch DNR TVhttp://www.dnrtv.com/default.aspx?showID=46

LucidInDreams:

Watch DNR TVhttp://www.dnrtv.com/default.aspx?showID=46

Thank you for the link but it explains how to build a tcp client; i would like to learn how to write a asp code for the asp sever side (tcplistener i think)


If you click on the TcpListener link in my above post, the page will show you an example of how to use that class.


So if your question is how to write client on Web, here is the answer:

<%@. Page Language="C#" AutoEventWireup="false" Trace="true" %><%@. Import namespace="System.Data"%><%@. Import namespace="System.Net"%><%@. Import namespace="System.Net.Sockets"%><script language="C#" runat="server">protected override void OnInit(EventArgs e){base.OnInit(e);this.Load += new EventHandler(this.Page_Load);}protected void Page_Load(object sender, EventArgs e){string host = "www.asp.net";string path = "/resources/default.aspx?tabid=41";int port = 80;string result = this.SocketSendReceive(host, port, path); this.Trace.Warn(result);}private static Socket ConnectSocket(string server, int port){Socket s = null;IPHostEntry hostEntry = null;// Get host related information.hostEntry = Dns.GetHostEntry(server);// Loop through the AddressList to obtain the supported AddressFamily. This is to avoid// an exception that occurs when the host IP Address is not compatible with the address family// (typical in the IPv6 case).foreach(IPAddress address in hostEntry.AddressList){IPEndPoint ipe = new IPEndPoint(address, port);Socket tempSocket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);tempSocket.Connect(ipe);if(tempSocket.Connected){s = tempSocket;break;}else{continue;}}return s;}// This method requests the home page content for the specified server.private string SocketSendReceive(string server, int port, string path) {// Create a socket connection with the specified server and port.Socket s = ConnectSocket(server, port);if (s == null)return ("Connection failed"); string request = "GET "+path+" HTTP/1.1\r\nHost: " + server + "\r\nConnection: Close\r\n\r\n";byte[] bytesSent = Encoding.ASCII.GetBytes(request);byte[] bytesReceived = new Byte[256];// Send request to the server.s.Send(bytesSent, bytesSent.Length, 0); // Receive the server home page content.int bytes = 0;StringBuilder sb = new StringBuilder();// The following will block until te page is transmitted.do {bytes = s.Receive(bytesReceived, bytesReceived.Length, 0);sb.Append( Encoding.ASCII.GetString(bytesReceived, 0, bytes) );}while (bytes > 0);return sb.ToString();}</script>

And if you are asking how to build web server, then my question is: Why not having web service if this will be web server based? In the dnrtv example they also have server by the way...


Thank you to all, really.

All yu helped me helped me for all i needed (sorry for my orrible english, i'm italian).

for LucidInDreams : thank you, no i don't need to build a web server, i was interested only to asp code tu build a socket connection. I was warried it was very different from c#, instead it is similiar :)

Thank you to all again! :)

Lewix