|
|
Hi.
Is it possible to change content of a WebBrowser object in C# without using HTML files ?
I mean :
For example we have following XHTML code :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test</title>
<style type="text/css">
<!--
body,td,th {
color: #000;
}
body {
background-color: #990;
}
-->
</style></head>
<body>
<table width="100%" border="1">
<tr>
<td align="center">TEST01</td>
<td align="center">test02</td>
</tr>
<tr>
<td><p>test03</p></td>
<td align="center">test04</td>
</tr>
</table>
</body>
</html>
Now , I wanna show the design in WebBrowser => http://img143.imageshack.us/img143/6855/50068901.png[^]
I would be appreciate if you guide me !
|
|
|
|
|
I do believe you can set the HTML of the control. If you can't, you can always save this HTML locally and point the control to it.
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.
|
|
|
|
|
Christian Graus wrote: I do believe you can set the HTML of the control.
Could you please guide me , which method or property do it in WebBrowser ?
|
|
|
|
|
Try DocumentText[^]
(Try having a look at the documentation some time - it realy is quicker than asking here...)
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
it's possible to change content of a webbrowser object in c# by using a string;
for example :
private void WriteHtml(string s){
//stream to string
MemoryStream ms = new MemoryStream();
try{
byte[] htmlcode = System.Text.Encoding.Default.GetBytes(s);
ms.Write(htmlcode,0,htmlcode.Length);
Stream dataStream = ms;
//Position
dataStream.Seek(0,0);
if(axWb.Document!=null){
//to IStream
(axWb.Document as UnsafeNativeMethods.IPersistStreamInit).Load(new UnsafeNativeMethods.ComStreamFromDataStream(dataStream));
}
}finally{
ms.Close();
}
}
modified 27-May-14 5:30am.
|
|
|
|
|
I have the following code snippet in a C# console application and am getting the following error in VS2008 on the last line (bool recExists = myReader.HasRows):
Error 2 Use of unassigned local variable 'myReader'
Here's the code:
string sResponse;<br />
SqlDataReader myReader;<br />
<br />
<br />
sQuery = "Select * from tracking where shipper_id = '" + sShipperId +<br />
"' AND shipper_ack = '" + sShipperAck + "'";<br />
<br />
myCommand1 = new SqlCommand(sQuery, conn);<br />
<br />
try<br />
{<br />
myReader = myCommand1.ExecuteReader();<br />
}<br />
catch (Exception e2)<br />
{<br />
conn.Close();<br />
conn.Dispose();<br />
<br />
sResponse = e2.GetBaseException().ToString() + " " + sQuery;<br />
<br />
}<br />
<br />
bool recExists = myReader.HasRows;
I use this same identical code in a Windows Client app with no problems.
What am I missing????
Thanks,
Dave
|
|
|
|
|
If that's a copy and paste of the code, it should work fine. I'm assuming there's something else that's not clear from what you copied and pasted. Is all of this an exact copy and paste of the whole function ?
Of course, it's not good code. You should check if myreader is null, because if execute reader blows up, it could well be.
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.
|
|
|
|
|
Change SqlDataReader myReader; to SqlDataReader myReader = null; and you should be fine
|
|
|
|
|
Excellent....
That worked great, but why do I need to set the value to null in the console app and not in the Windows Forms app????
|
|
|
|
|
(Just a guess since I don't know all your code) Maybe the SqlDataReader used to be a field instead of a local? Fields are initialized automatically whereas locals aren't so they often need explicit initialization
|
|
|
|
|
Oh - yeah, I see the issue now. That is really dumb, IMO, I've had that happen too.
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.
|
|
|
|
|
Try your code like this:
string sResponse;
SqlDataReader myReader;
bool recExists = false;
// Check existence of tracking record
sQuery = "Select * from tracking where shipper_id = '" + sShipperId +
"' AND shipper_ack = '" + sShipperAck + "'";
myCommand1 = new SqlCommand(sQuery, conn);
try
{
myReader = myCommand1.ExecuteReader();
bool recExists = myReader.HasRows;
}
catch (Exception e2)
{
conn.Close();
conn.Dispose();
sResponse = e2.GetBaseException().ToString() + " " + sQuery;
}
// for example
return recExists;
Hope this helps
|
|
|
|
|
change "SqlDataReader myReader;" to "SqlDataReader myReader = null;"
and try again.
modified 27-May-14 5:30am.
|
|
|
|
|
Hai friends I am facing some problems while operating powerpoint using c# application. The problem is I was able to operate the powerpoint only when I am opening it or creating it by c# application. Does any of you have ideas on how to operate the powerpoint, which is already opened in the system.
|
|
|
|
|
vijay_varma86 wrote: Does any of you have ideas on how to operate the powerpoint, which is already opened in the system.
What do you mean by operating?
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
OOPS! I mean moving the powerpoint slideshow back and forth
|
|
|
|
|
I am not sure that's possible. I know you can work with powerpoint using the office toolkit, in .NET, but I don't know if Office allows an external program to find instances already running, and control them.
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.
|
|
|
|
|
This is the first time i've used a FileSystemWatcher, so i might well be doing something very basic wrong. The code below is what i use to start the FileSystemWatcher.
_fileSystemWatcher = new FileSystemWatcher(path, "*.sql");
_fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
_fileSystemWatcher.Created += new FileSystemEventHandler(FileSystemWatcher_Created);
_fileSystemWatcher.Error += new ErrorEventHandler(FileSystemWatcher_Error);
_fileSystemWatcher.EnableRaisingEvents = true;
But, i never seem to get an events raised. The path is set to the correct folder and i am creating files with an sql extension when my program runs, so i thought i would see some info.
I am running Win7, if thats any help...
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
I just try your code, it works if you remove the line with "NotifyFilter".
|
|
|
|
|
Cheers.
I changed it to "NotifyFilters.FileName", as i am only interested in new files being created.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
Hi,
but filewatcher costs process overload.
why cant you try with API Hooking
you can track all the newly opened files and even you can block creating/edit/delete file activities.
unless i know the situation for what you are using filewatcher i cant suggest even hooking.
|
|
|
|
|
The app is going to be very small. All it does is watch a folder, if new files are created, alert the user and then the user runs something in the program.
At the moment it is using 11k of memory, so i dont think this is an issue. Its also an internal app, so i know what systems it will be run on, and they are fast.
Regards,
Gareth.
(FKA gareth111)
|
|
|
|
|
hi,
Ya fine ! you are correct,
i have given the situation where the file watcher is done for the entire system(all the logical and removable drives)
as you mentioned for watching one folder, it wont cost performance issues.
do proceed...!
|
|
|
|