|
Translation:
"ummmmmmmmm..."
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
You can get the text by using the WebBrowser.DocumentText property. Simply retrieve that data, liminate the stuff you want to filter, and set it back to the new version of the data.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
But how do you add a URL such as "http://gmail.com" is a WebBrowser retrieves the contents of the entire page with pictures (JPG, SWF ...). And I do not want to download them.
|
|
|
|
|
Use the WebClient class to retrieve the page, massage the returned html, and set the WebBrowser.DocumentText property to the massaged URL.
using System.Net;
string url = "http://www.mywebpage.com/";
Uri uri = new Uri(url);
WebClient webClient = new WebClient();
string response = "";
try
{
response = webClient.DownloadString(uri);
}
catch (Exception e)
{
if (e != null) { }
}
this.webBrowser1.Navigate("about:blank");
HtmlDocument doc = this.webBrowser1.Document;
doc.Write(string.Empty);
this.webBrowser1.DocumentText = ProcessWebPage(response);
ProcessWebPage would be a function you write to filter the results. You gotta learn to think around problems instead of through them.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
OK. Thank you!
But the matter is this:
[Code C #]
webBrowser1.Navigate (new Uri ( "http://gmail.com"));
HtmlDocument doc = webBrowser1.Document;
doc.GetElementById ( "Email"). setAttribute ( "value", "login");
doc.GetElementById ( "passwd"). setAttribute ( "value", "password");
doc.GetElementById ( "signIn"). InvokeMember ( "Click");
I have to move to a new address in the WebBrowser. WebBrowser must parse page. JavaScrypt process. And so to avoid manual transmission parameters POST and GET. In WebClient i must manual set parameters POST and GET. Sometime it is very difficult.
|
|
|
|
|
If you're going to continue to feed me requirements piece-meal like this, I'm done with trying to help you.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I want to create a batch file that should run 3 different .exe that are placed in a single folder and the location of the folder could be anywhere in the system. Is there a command in batch file that allows me to run the .exe from their current location? Please help
Cheers!
Ethen
|
|
|
|
|
Googe the Process class.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello World...
I want to connect to a sql server 2000 db remotely(Lan Network).
I write a c# test project and set server, my server IP but after run it ,give me this error: Time out, your server computer not response.
I beleve, i must to configure my server sqlserver but ...!!!???
sry for my very bad en...
TanX World...
|
|
|
|
|
I think it is because of your ConnectionString, do you addressed your SqlDB correctly, in ConnectionString?
While (true) { Human.isLearnable = true; }
|
|
|
|
|
my connectionstring is corrent because when I change my server Name to (local) my app haven't any error...
...
|
|
|
|
|
Basically three possibilities:
1. Your SQL Server isn't configured to use TCP/IP, use Configuration Manager at server
2. Your connection string is faulty, bad ip-address, port etc
3. IP traffic isn't routed to server, for example because of an firewall
The need to optimize rises from a bad design
|
|
|
|
|
- In sqlserver I see tcp/ip connection & I ticked it...
- If my connectionstring faulty ,i can not connect with it localy...
my connectionstring:
public void Connect()
{
string cs = "Server = 192.168.10.190; database = DB1; user=u1; password=123";
con.ConnectionString = cs;
con.Open();
}
|
|
|
|
|
Few questions:
- is the SQL Server running on the same computer where you're running the app?
- if you can connect to it locally but not remotely, what's the difference in connection string?
The need to optimize rises from a bad design
|
|
|
|
|
diference of it , is i change servername to (local)...
I have some pc with Lan network in one of these I have sqlserver with my database, and in other pcs i have app for connect to that.
|
|
|
|
|
Then the three choices I listed are most common reasons. It's a very different situation to use IP than to connect to localhost.
Few things you should check,
- try to ping the IP-address
- check on server side that the listening port is 1433 or if it isn't, specify the correct port in connection string
- check on server side that the other pc can listen to port 1433 (no Windows firewall blocking)
- check that it isn't a named instance on the server or if it is, specify the instance name in connection string
The need to optimize rises from a bad design
|
|
|
|
|
hi all.
i need to make a call to a method asynchronously. this method accepts arguments. the method also returns a value that is then used to modify a form obviously created by the main thread.
to keep things simple, i created a prototype of what i'm trying to do. here's the code:
public partial class Form1 : Form
{
public delegate int SomeMethod();
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
SomeMethod method = IntFetcher.SlowFetch;
method.BeginInvoke(EndFetchInt, method);
}
public void EndFetchInt(IAsyncResult result)
{
SomeMethod method = result.AsyncState as SomeMethod;
int i = method.EndInvoke(result);
MethodInvoker mi = new MethodInvoker(this.AddToList);
this.BeginInvoke(mi, i);
}
public void AddToList()
{
int i = 0;
ListViewItem lvi = new ListViewItem();
lvi.Text = i.ToString();
lvi.SubItems.Add(DateTime.Now.ToString());
listView1.Items.Add(lvi);
}
public void AddToList(int data)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = data.ToString();
lvi.SubItems.Add(DateTime.Now.ToString());
listView1.Items.Add(lvi);
}
}
public static class IntFetcher
{
public static int SlowFetch()
{
Thread.Sleep(3150);
Random random = new Random(DateTime.Now.Millisecond);
return random.Next(100, 500);
}
}
I had to create the AddToList() method to be confirm if the code was being called at all and to determine if it could modify the listview control. It did. But i still couldnt figure out a way to pass the value returned from the function to it.
I used MethodInvoker cos without it, I got an exception telling me that the running thread could not modify the control as it was created by the main thread.
Any contributions will be appreciated. Thanks.
|
|
|
|
|
|
i still got this exception
Cross-thread operation not valid: Control 'listView1' accessed from a thread other than the thread it was created on.
while calling the AddToList() method directly from the callback method using the procedure outlined on that url.
combed thru msdn and got this url http://msdn.microsoft.com/en-us/library/ms171728.aspx which is supposed to help make thread-safe calls to windows form controls.
trying to understand the methods outlined there.
|
|
|
|
|
First, based on documentation for MethodInvoker : This API supports the .NET Framework infrastructure and is not intended to be used directly from your code
Second, presumably the MethodInvoker executes the method passed in another thread so it basically the problem is exactly what the error says.
Take a look at BackgroundWorker Class[^]. I believe it would be helpful in your case.
The need to optimize rises from a bad design
|
|
|
|
|
Thanks Mika, but i got it working already. the problem i had was marshalling the background thread to the main one. this was the modification i made to get it to work.
public void EndFetchInt(IAsyncResult result)
{
SomeMethod method = (SomeMethod)result.AsyncState;
int i = method.EndInvoke(result);
AddToList(i);
}
delegate void _addToList(int data);
public void AddToList(int data)
{
if (this.listView1.InvokeRequired)
{
this.Invoke(new _addToList(AddToList), data);
}
else
{
ListViewItem lvi = new ListViewItem();
lvi.Text = data.ToString();
lvi.SubItems.Add(DateTime.Now.ToString());
listView1.Items.Add(lvi);
}
}
i would have had to do the same if even if i had used the BackgroundWorker class.
|
|
|
|
|
Glad you got it solved!
Yeah, you have had to do the same in every implementation, but there was these two reasons why I suggested BackgroundWorker:
- if I understood correctly, MethodInvoker shouldn't be used. If it's internal, it's not well documented and there are no quarantees for backward compatibility in future versions
- with BW the model is easier to implement and therefore also more understandable
But then again, are those valid reasons at all fully depend on your needs.
Happy coding
The need to optimize rises from a bad design
|
|
|
|
|
|
Your code works. I replaced the createMailBody with the string directly.
string strImage = "TestImage.gif";
string strTitle = "HTML File";
string strMailBody = @"<html><body> <table> <tr> <td><img src="$image$"/></td> <td> $title$</td> </tr> </table></body></html>";
strMailBody = strMailBody.Replace("$image$", strImage);
strMailBody = strMailBody.Replace("$title$", strTitle);
I assume the problem is that you don't get the right string from the createMailBody method.
Eslam Afifi
|
|
|
|
|
Sorry for delay...
iam using this to send a mail. Problem is, at the receiver end image doesn't display. How to solve this?
|
|
|
|