Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[c#] Client > Server - textbox

Joined
Dec 1, 2007
Messages
2,795
Reaction score
480
Well I'm just messing about with a packet logger and say if I want to inject the 'BK' and use the text from txtAlert
BK - message box popup

Code:
        private void cmdAlertCS_Click(object sender, EventArgs e)
        {
            clsSockets.SendToClient("BK" + txtAlertCS);
        }

But when I have like 'Hey there!' and I send the packet to client, the BK alert comes up fine but it comes out like;

Code:
System.Windows.Forms.Textbox, Text: Hey there!

But I don't want the 'System.Windows.Forms.Textbox, Text:' to come up.

Does anyone know how to counter this?
 
Experienced Elementalist
Joined
Dec 27, 2006
Messages
288
Reaction score
4
By using 'txtAlertCS' which is a TextBox object (and not text), the ToString method is implicitly invoked to convert the object to a string, which results in 'System.Windows.Forms.Textbox, Text:'. The solution is to use the 'Text' property of txtAlertCS, which will return the text contained in the text box.

How it should be:
Code:
        private void cmdAlertCS_Click(object sender, EventArgs e)
        {
            clsSockets.SendToClient("BK" + txtAlertCS.Text);
        }
 
Joined
Dec 1, 2007
Messages
2,795
Reaction score
480
By using 'txtAlertCS' which is a TextBox object (and not text), the ToString method is implicitly invoked to convert the object to a string, which results in 'System.Windows.Forms.Textbox, Text:'. The solution is to use the 'Text' property of txtAlertCS, which will return the text contained in the text box.

How it should be:
Code:
        private void cmdAlertCS_Click(object sender, EventArgs e)
        {
            clsSockets.SendToClient("BK" + txtAlertCS.Text);
        }

Thanks, I knew there was a simpler way to do it.
 
Back
Top