|
Hi
I am looking for help and an example because I want to create an HTML output from a C# app that provides the usual html tags along with a html table with data coming from an object. Does anyone have an example I can follow?
|
|
|
|
|
StringBuilder ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I expect an XmlDocument could do it.
|
|
|
|
|
I think the best way is XML+XSL,but it is not easy and convenient.
|
|
|
|
|
Is the syntax correct? The error that I get is :No overload for method 'CopyTo' takes '1' arguments
//The SortedList.CopyTo() method copies the current sortedlist to an array.
Example
SortedList items = new SortedList();
items.Add("key2", 5);
items.Add("key1", 2);
items.Add("key3", 9);
String[] MyArray = new String[4];
items.CopyTo(MyArray);
MyLabel.Text = "Third item of SortedList is "+MyArray[2];
|
|
|
|
|
Message Closed
modified 23-Nov-14 7:02am.
|
|
|
|
|
will that copy all the values into the array of the sorted list?
|
|
|
|
|
Hi
I am using a OleDb DatabaseConnection, and I am using this connection to take in and read in an excel spreadsheet into an Object.
However, I would like to get the number of rows the DataReader has brought back in order to use in a for loop. I thought, by using another SQL Query, would do the job, but when I run this, it says that the reader has no results to return, which is odd because the main query that is bringing back the rows - works!!! So, does anyone know how to get the count on the number of rows a datareader would bring back from reading in the rows from an excel spreadsheet?
|
|
|
|
|
Good afternoon.
I have a webrowser control on my main form and on the form load I set the URL for the control
When the webpage loads, the focus stays on the webpage and I cannot seem to programatically move the focus to the combobox on the form.
I even set the focus on the webbrowser control to False.
Any suggestions?
Thank you, WHEELS
|
|
|
|
|
Set the ComboBox on the top in the tab order. If that doesn't work, hook up a method to the DocumentCompleted event of the web browser control and set the focus to the ComboBox there.
|
|
|
|
|
Hi Shameel.
I did experiment with DocumentCompleted yesterday before I posted, but neither 'method' worked. Not sure hwy DocumentCompleted doesn't work though.
However, I did get this to work:
private void WebBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e)
{
this.cboSP_Site.Focus();
}
I appreciate your willingness to assist. Have a great day, WHEELS
|
|
|
|
|
ProgressChanged would fire more than once (probably many times) during a single page load, so you end up setting focus many times
|
|
|
|
|
I noticed that, but what can I do?
WHEELS
|
|
|
|
|
DocumentCompleted SHOULD fire when document is completed loaded. Try to find out why it is not working.
|
|
|
|
|
Thank you Shameel. That will be my primary focus today. However, one thing I noticed, is that some web pages hijack the focus (e.g. Google), 'holding' it in the search box. My feeling is that when this occurs, the DocumentCompleted will not fire.
WHEELS
|
|
|
|
|
I just created a small app to see myself what the problem is, and as you said, setting focus to the other control in DocumentCompleted event doesn't work. The reason I found is that DocumentCompleted is fired when the browser completes loading the html content of the page and google runs a javascript in its onload event to set focus to the search box. This happens after the DocumentCompleted event executes and therefore focus goes back to the control.
But ProgressChanged event works, and I found a workaround to do away with setting focus multiple times. Use this code:
private void webBrowser1_ProgressChanged(object sender, WebBrowserProgressChangedEventArgs e) {
if (e.CurrentProgress == e.MaximumProgress) {
textBox1.Focus();
}
}
|
|
|
|
|
Works great. Thank you. WHEELS
|
|
|
|
|
how could i change this code to use the DirectorySearcher to get me all members in the group the reason i want to use the DirectorySearcher is because i can set the PageSize so i can get more than 1,000 users
currently all these groups have over 2,000 users
public static ArrayList testGetUsers()
{
ArrayList excludeGroups = new ArrayList();
ArrayList users = new ArrayList();
DirectoryEntry group;
excludeGroups.Add("CN=GMDPortal,OU=IT,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GService,OU=SysServices,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GTrain,OU=Training,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
excludeGroups.Add("CN=GITLevSvcs,OU=LevSvcs,OU=IT,OU=ADM,DC=corp,DC=ad,DC=ejhospital,DC=com");
foreach (string DEgroup in excludeGroups)
{
group = new DirectoryEntry("LDAP://" + DEgroup);
foreach (object dn in group.Properties["member"])
{
users.Add(dn);
}
}
return users;
}
|
|
|
|
|
Hello,
i've wrote a server-application which should be able to hold a huge amount of TCPConnections (TCPClients).
I receive the messages asynchrone and every TCPClient is running in another Thread. Now, has somebody any experience in performance? How many Clients can i hold? Do i have any performance-issues if i hold them only (so no receiving and really working) and how many memory do they need? How many users are possible? 10...1000....1 000 000?
If somebody has any experience with that topic please share your experience.
Many thanks
softwarejaeger
|
|
|
|
|
Well, TCP/IP ports are int16 (so, 65536 values are possible), but some ports are already reserved, I think 0 is invalid, and so I must say the maximum possible connections are 60000.
I do not know how many memory they utilize, but for 64bit machines I think is very easy to use all of them.
And, if they are not sending data, they will only consume memory.
|
|
|
|
|
Server applications should only use one local port for communications, so the 65535 limitation on the port number doesn't affect the number of possible threads.
|
|
|
|
|
That's wrong.
Server applications use one port for Listening.
Each client connection then uses another port.
So, a server with 10 clients will use 11 ports:
1 port to listen for new clients,
and 1 port for each connected client.
|
|
|
|
|
Here's a simple server program demonstrating how the ports work. It'll accept 10 connections, hang onto each one for 30 seconds, then shut itself down. Telnet into port 2323 with a command prompt to connect. If you connect 3 clients, netstat will yield a similar output to this (client ports are random, so it's not exact):
Proto Local Address Foreign Address State
TCP workstation:1161 localhost:2323 ESTABLISHED
TCP workstation:1162 localhost:2323 ESTABLISHED
TCP workstation:1163 localhost:2323 ESTABLISHED
TCP workstation:2323 localhost:1161 ESTABLISHED
TCP workstation:2323 localhost:1162 ESTABLISHED
TCP workstation:2323 localhost:1163 ESTABLISHED
The client's ports are randomly assigned to a number over 1024, but note that the server will always use port 2323 for its communication. When a client connects, the server does not create a new connection on a secondary port for communications.
However, some protocols do work like you have described above, randomly using an additional port for a secondary connection (IE, FTP does for data transfers, which is why FTP servers behind firewalls are a pain in the butt ).
Server Code -
[STAThread]
public static void Main(string[] Args) {
TcpListener listener = null;
try {
listener = new TcpListener(IPAddress.Loopback, 2323);
listener.Start();
int connection_count = 0;
while(connection_count<10) {
if(listener.Pending()) {
TcpClient connection = listener.AcceptTcpClient();
ThreadPool.QueueUserWorkItem(new WaitCallback(Communicate), connection);
Console.WriteLine("Connection Accepted ({0})", connection_count++);
}
Thread.Sleep(1);
}
Console.WriteLine("Waiting 30 seconds for last connection to close.");
Thread.Sleep(30005);
Console.WriteLine("Shutting Down.");
} finally {
if(listener!=null) {
listener.Stop();
}
}
}
private static void Communicate(object Connection) {
if(Connection==null) return;
TcpClient client = (TcpClient)Connection;
StreamWriter writer = null;
try {
if(client.Connected) {
writer = new StreamWriter(client.GetStream());
writer.WriteLine("Connected. You will be disconnected in 30 seconds.");
writer.Flush();
Thread.Sleep(30000);
writer.WriteLine("Bye!");
writer.Flush();
}
} catch {
if(writer!=null) {
writer.WriteLine("Connection error.");
writer.Flush();
}
} finally {
Console.WriteLine("Closing Client.");
if(client.Connected) {
client.Close();
}
}
}
|
|
|
|
|
You are wrong.
Maybe the results are as you showed, but try showing the IP address of this:
TcpClient connection = listener.AcceptTcpClient();
This connection does not use the same port as the listener port. At least not in my computer.
|
|
|
|
|
connection.Client.LocalEndPoint shows the servers IP address and listening port (in my example, 127.0.0.1:2323). The connection.Client.RemoteEndPoint is the client address/port that is connecting to the server, which does have a randomly selected port above 1024.
|
|
|
|