|
Hi Guys.
I am having a situation here, i want to read a dynamically textarea content,
String CommentOut = null;
for (int intX = 0; intX < dt.Rows.Count; intX++ )
{
CommentOut += "<div class='commentBox'><table><tr><th>" + dt.Rows[intX][2].ToString() + " on:" + dt.Rows[intX][1];
CommentOut += "</th></tr><tr><td bgcolor='#f5f1f1'>" + dt.Rows[intX][4].ToString() + "</td></tr><tr><td class='commentBoxIns'>";
Quir = "Select Username_ as 'Posted By', comment_ as 'Comment', Date_ as 'date' ";
Quir += " From CommentsTBL_ where CommentID_ = '" + dt.Rows[intX][0].ToString() + "'";
SqlCommand Sqlcom2 = new SqlCommand(Quir, Con);
SqlDataAdapter Adapt2 = new SqlDataAdapter(Sqlcom2);
DataTable dt2 = new DataTable();
Adapt2.Fill(dt2);
for(int intY=0; intY<dt2.Rows.Count; intY++){
CommentOut += "<table width='70%' align='right'></tr><th>" + dt2.Rows[intY][0].ToString() + " on:" + dt2.Rows[intY][2].ToString();
CommentOut += "</th></tr><tr/><td>" + dt2.Rows[intY][1].ToString();
CommentOut+= "</td></tr></table>";
}
Adapt2.Dispose();
dt2.Dispose();
Sqlcom2.Dispose();
CommentOut += "</td></tr><tr><td><textarea id='comment" + intX + "' name='comment" + intX + "' rows='5' cols='20' style='width:97%;' runat='server'>type your comment here</textarea>";
CommentOut += "</td></tr><tr class='commentBoxCom'><td><a href=?ID1=" + dt.Rows[intX][0].ToString() + "&ID2=comment" + intX + ">Comment</a>";
CommentOut += "</td></tr><tr><td>";
CommentOut += "</table> </div><br/>";
}
this.LitCont.Text = CommentOut;
|
|
|
|
|
You'll need to be more specific. Please edit your question and tell us what the specific issue is. What have you tried that isn't working? Is it throwing an error? If so, tell us what it is. Some general information about what you are trying to do would be helpful and an idea of how this fits into the bigger picture.
Your post, as-is, is way too generic. You have dumped your car at the mechanic and said, "something is wrong." Imagine for a moment that we have no idea what you are doing and pretend that we need to be told all of the information you have about the problem.
|
|
|
|
|
|
OK... you explained your code and provided some additional code but you still haven't told us what the problem is. What are you trying to do? What is the problem? What have you tried that isn't working?
Unless you can define the desired behavior and how your code is deviating from that, we can't help you. Nobody can look through what you have posted to find an error that you haven't defined.
|
|
|
|
|
Ok i am sorry i am having dificulties in explaining myself, but the idea i had in mind is to create a textarea using a c# code, and i managed to do that well but i can not figure out any other way of reading from the text area that i have created, and when i am trying to read from it i get blank results(as if it is null)
|
|
|
|
|
I'm still not completely sure what you are trying to do but I'm guessing that you are rendering a table of results and are looking for the comments that a user puts into the page. Am I on the right track here?
If this is the case, you are going about it the wrong way. You are generating an HTML page with your code. Once you pass that on, it is rendered in a browser on the client machine. Your code has no direct link to that rendered page. The same as if you rendered the page in ASP on a server and sent it to the client. The server no longer has any reference to that document once it is transmitted to the client end.
To get back what a user enters into a web page, the document needs to be posted back to the server or you need to do some sort of AJAX call so the data is sent back. Both of these are client side operations. If you are rendering the page inside of a browser control, you might be able to access the DOM in that control and get at the data.
I'm not an expert in client side web development. You might be better off asking in the ASP forum.
However, if you are doing this in a C# winforms or WPF app, I would ask why you are rendering table-type data in a web page rather than using a data grid or something like that?
|
|
|
|
|
Hi Jason, thanx alot for taking your precious time and try to listen and for helping me out,
Your guessing was correct, okay I heard you there when you suggested that I should look into Ajax to make that happen,
The reason for me to use the table instead of the gridview is pretty much not that necessary because all I wanted to use something different than I can actually control the look and feel of the interface, I also felt like I have relied too much on the gridviews... the bottom line is, I wanted something different
|
|
|
|
|
Oddly is that when I send the 9 character length of a string (i.e. 123A45678), my serial port dataReceived event recieves the message but it reads as:
123A4567
8
Unsure on how to get the whole string as was sent by the other com port?
here's my code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO.Ports;
using RS232;
namespace RemoteCFG
{
public class RemoteConfiguration
{
SerialPort serialPort;
RS232Comm rs232Comm = new RS232Comm();
Object lockingObj = new object();
public RemoteConfiguration()
{
}
public string strMessage { get; set; }
public string cfgNumber { get; set; }
public string vloValue { get; set; }
public string atcValue { get; set; }
public List<string> EnumerateComPorts()
{
return rs232Comm.GetAvailableComPorts();
}
public int OpenPort(string comPort)
{
serialPort = rs232Comm.OpenPort(comPort);
serialPort.DataReceived +=new SerialDataReceivedEventHandler(serialPort_DataReceived);
if (serialPort != null)
return 1;
else
return 0;
}
public int ClosePort()
{
try
{
serialPort.Close();
return 1;
}
catch (Exception ex)
{
return 0;
}
}
void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
SerialPort sp = (SerialPort)sender;
string inData = sp.ReadExisting().Trim();
strMessage = inData;
switch (inData)
{
case "PLC": SendMsg("OK"); break;
case "CFG": ValidateCFG(); break;
case "OFF": serialPort.Close(); break;
case "VLO": GetVLO(); break;
case "ATC": GetATC(); break;
default: System.Diagnostics.Debug.WriteLine(strMessage); break;
}
}
private void GetATC()
{
if (atcValue != null && atcValue != string.Empty)
{
int value = 0;
if (int.TryParse(atcValue, out value))
{
if (value >= 0 || value <= 99)
{
SendMsg(atcValue);
}
}
}
}
private void GetVLO()
{
if (vloValue != null && vloValue != string.Empty)
{
int value = 0;
if (int.TryParse(vloValue, out value))
{
if (value >= 60 || value <= 120)
{
SendMsg(vloValue);
}
}
}
}
private void ValidateCFG()
{
if (cfgNumber != null && cfgNumber != null && cfgNumber != string.Empty)
{
if (cfgNumber.Length == 9)
{
try
{
int Num = 0;
if (int.TryParse(cfgNumber.Substring(0, 3), out Num))
{
int errorCounter = System.Text.RegularExpressions.Regex.Matches(cfgNumber.Substring(3, 1), @"[a-zA-Z]").Count;
if (errorCounter == 1)
{
if (int.TryParse(cfgNumber.Substring(4), out Num))
SendMsg(cfgNumber);
}
}
}
catch
{
}
}
}
}
public int GetCFG(ref string configNumber)
{
int status = 0;
try
{
SendMsg("CFG");
configNumber = strMessage;
}
catch
{
}
return status;
}
int GetDynData(string[] dynamicData)
{
int status = 0;
return status;
}
public int SendMsg(string msg)
{
int status = 0;
serialPort.Write(msg + "\r");
return status;
}
}
}
The serial port is initilized as:
serialPort = new SerialPort(comPortName, 9600, Parity.Even, 7, StopBits.One);
serialPort.Handshake = Handshake.XOnXOff;
|
|
|
|
|
You serial port is set at 9600 baud - this is not a fast speed, certainly not in modern terms.
9600 baud means 9,600 bits per second, so with 1 start bit, one stop bit, even parity and 7 bits per character that's a maximum data transfer rate of 960 characters per second.
You SerialPort.DataRecieved event does not fire when the final character is received, it fires when the first character is received. And the second, and the third....
So when you read all the data from the serial port buffer, you will get a "random" number of characters, which may - or may not be - the whole message you are looking for.
Instead of your existing code, set up a BackgroundWorker thread which processes input data from the serial port, scans it to find whole messages, and then signals up to the main thread that a whole message is ready. If it gets a "partial message" is stores it, and adds the next data on the end before scanning it again.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
You don't need a background worker and the baud rate has nothing to do with your ability or inability to receive a message.
The SerialPort class already operates on its own thread. The truth is the physical serial port on your PC is implemented with a USART and has no buffer of its own. It can hold a single character. When it receives data, it fires an interrupt. The interrupt handler adds the character to a FIFO buffer and notifies the serial port class attached to that port that a character has been received. That message goes into the message queue and your application will receive it via the DataReceived event when the message pump gets around to sending it to your app.
When you read the data from the serial port class, you empty the FIFO buffer either in one swoop or a character at a time. Interlocks are already built into the serial port class so you don't contend with any characters that may be received at the port while the data is being read by the application. For all intents and purposes, you read a string of characters as they have been received up to that point in time.
What is NOT present is any kind of message framing. And that is where you need to do something. The fact is the DataReceived event could be fired for every character that comes in the serial port. You have to grab those characters, append them to a message string, then determine when the message is complete. It is the same as information coming from the keyboard... the user types a single character at a time. If you are looking for a word, you buffer those characters onto a string until you see a space or a carriage return. Same this with the serial port... just think of it as another keyboard where characters arrive (not full strings!).
So you need to decide what your message delimiter is. Normally, for serial communications, the message is ended with a 13... a carriage return. Since it looks like you might be talking to a PLC for data collection, it may also be a fixed-width situation. In that case you need to test the length of the accumulated string each time DataReceived is called. Either way, you need to look for the delimiter or the length in DataRecevied and THEN process your results once the whole string has been received. Make sense?
Secondly, you are casting the serial port from the event arguments. You shouldn't do that. You already have a reference to the serial port in your class-scoped serialPort object. Use it inside of the event handler.
Usually, inside of this event, you setup a While loop that looks at the character count on the serial port. If it is greater than 0, you pull a single character with ReadChar(), check to see if it is your message delimiter, then tack it onto strMessage if it isn't. If it is your delimiter, you pass the message to the processing function and set strMessage to string.empty when you are done.
Remember that DataRecieved is called on a different thread because it is raised by the serial port class. This means your message processing will take place on the worker thread too. If you want to interact with the UI, you will have to marshal the call over to the UI thread.
HTH!
|
|
|
|
|
Hello,
How can I paste outside my application via mouse clicks, When I click in any textbox outside my application it paste from the clipboard ?
I'm already have a code to detect the mouse events but I don't know how to paste outside my windows application
so please provide a good explain and a small example.
Regards
JusT LeT YouR MinD WorK
|
|
|
|
|
"When I click in any textbox outside my application it paste from the clipboard ?"
This doesn't quite make sense: other applications running, that you haven't created, may, or may not, have text-entry fields that allow pasting. If they do, you can just use keyboard Control-V to paste, once you've clicked inside the other application to set the insertion cursor in a Control that allows pasting. Why do you need "more" than that ?
Yes, you can use API calls to find out what window the mouse clicked on "outside your application," but then: how do you discover what kind of control in this other application (you have no control over) they clicked on ? How do you know they clicked on a control that allowed pasting in of text ?
So, could you clarify exactly what you mean by "textBox outside my application," and why would you want to use some mouse-click combination to paste.
yours, Bill
~
“This isn't right; this isn't even wrong." Wolfgang Pauli, commenting on a physics paper submitted for a journal
modified 27-Aug-13 0:34am.
|
|
|
|
|
well I will explain what I want to do.
I have a windows application which is ready to receive some data from the user then make some operations on it then get out the results.
Then the user have to copy the data from the application to store it on webpage to save it on the server.
So what I want to do is to send the results from the the application to the webpage programmatically but I think its not easy, So I think it will be helpful if I made the user paste by doing a double click which I will copy the data from the windows app to clipboard and change it when the user paste on the webpage.
so any other good suggestion for this ?
JusT LeT YouR MinD WorK
|
|
|
|
|
Mahmoud EL-Shazly wrote: copy the data from the application to store it on webpage to save it on the server
That means: there is a web page with a "FORM" element, and on "SUBMIT" the data are transfered to the web server with a GET or - more likely - POST request to a specific URL. Why don't you just do some reverse engineering, and have your application send the data directly to that URL? .Net components for that purpose are available.
|
|
|
|
|
I'm not the developer of that web application I can just use it, so I cannot edit it
All what I need to send the paste action from my application to the windows by double click in any textbox out of my application
as I said I already have a code to detect the mouse events anywhere but I don't know how to send the command to the windows to do the paste action... Will the API help ?
JusT LeT YouR MinD WorK
|
|
|
|
|
In your situation you don't need to paste at all!
Examine the html source of the webpage that you have been trying to paste into. You need to replicate that functionality in your code and send the data (either post or get) directly to the web server programmatically from your application. All the information you need about the expected data to make this work is already in the html source.
|
|
|
|
|
I can detect the mouse clicks in/outside my application
I just want to send WM_PASTE using API to windows so it will execute the paste command.
----------------------------
I need to do that because the user needs to take some data from the customer then enter it to a webpage more than one time and this takes a long time so I want to the user able to store the data in my application then paste them into the webpage faster, this will save a lot of time and of course a lot of money.
I can handle it if the user used it with a control that don't allow pasting in on it.
Now all what I need is to send the paste command to windows successfully.
JusT LeT YouR MinD WorK
|
|
|
|
|
Not so easy. You need a global mouse hook to discover the mouse anywhere. When a click happens, you have to find out the type of the control clicked. In case of "common" textboxes, you can then send the keys for inserting from the clipboard.
It may fail with Java applications when they use "swing".
|
|
|
|
|
Don't post the same question in multiple places - it duplicates work and can annoy people.
You have already posted this in QA, so work with the version there.
This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre.
Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.
|
|
|
|
|
I didn't mean to duplicate my post in many places and if it done I'm sure it done by fault... sorry
JusT LeT YouR MinD WorK
|
|
|
|
|
Question -
There're many obfuscators in the market - what happen if you obfuscate an exe which is NOT signed with a strong name? Strong name - is if you want to install your dll's into GAC, or that you want runtime to check if the binary has been tampered with.
http://www.eziriz.com/help/source/main_panel.html[^]
Take .NET Reactor for instance, it can sign an exe WITHOUT a strong name, with anti tampering/anti disassembly options. In this case, what's the point of having a strong name?
MSDN says ...[^]
dev
modified 26-Aug-13 19:13pm.
|
|
|
|
|
You can always obfuscate a dll which is not signed.
You just can put it in the GAC.
An exe would normally not go into the GAC in any case.
|
|
|
|
|
Bullshit from "MSDN says"
"Strong names offer a powerful mechanism for giving .NET Framework assemblies unique identities. ... mentioned, the .NET Framework verifies the signature either when loading the assembly or when installing it in the GAC. Without access to the private key, a malicious user cannot modify your code and successfully re-sign it."
With all this complication, it has nothing against tampering (If you want anti tampering, buy obfuscation tool from vendor). Unique name? Why not I just read md5 signature? Why bother strong name?
M$ recent years has just been too busy inventing useless sh*t.
For those of you who want to read this bullshit[^]
dev
|
|
|
|
|
devvvy wrote: Why bother strong name?
I load my stuff using the strong name; the fact that it's unique makes it a bit harder to register a new dll on the machine with the same name.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
devvvy wrote: Why not I just read md5 signature?
Who told you a MD5 hash was unique to only one assembly? That's simply not true. It's rare that two different streams of bytes can come up with the same MD5 hash value, but it is possible.
MD5 is not considered secure anymore. It's too easily broken.
But, it's still just barely useful enough to be a factor in a multiple-factor identification scheme.
|
|
|
|
|