|
Hi,
I want to convert javascript functions Relative URL to absolute URL.
I have all the javascript urls extracted from a web page this being done from the HTML DOM of web page and the page is being browsed in webbrowser control in my c# project.
I want to get the absolute url of a javascript function. Presently i using the simulating the onclick event of Browser through MSHTML and capturing the url in beforenavigate event but that ends up in a chaos as it sends reuqest for navigation and takes up time. This scenario is quite cumbersome in cases
where there are a no. of javascript functions and for each a request is being sent.
One possible way is to stop the browsing once i have the url, however that doesnt seems to be a good way to solve the problem.
some examples
javascript:OpenPage('http://google.com');
Absolute Path:- http://google.com
javascript:LinkToPage2('/sports','/games.htm')
This being on the domain of yahoo.com so
Absolute Path:- http://www.yahoo.com/sports/games.htm
--
some code
---
for(int j = 0; j < anchors.length; ++ j)
{
link = (mshtml.IHTMLAnchorElement)anchors.item(j, null);
if (link.href.ToLower().StartsWith("javascript:"))
{
ele = (mshtml.IHTMLElement)link;
if (cnt == count)
{
currentEle = ele;
currentDoc = doc;
found = true;
break;
}
---
more code
---
currentEle.Click()
}
Now capturing the url in before navigate event
private void BeforeNav(object sender, NavigateEventArgs arg)
{
try
{
string Url = arg.Url
----
----
Any suggestions!
the woods are lovely dark and deep.
but i have promises to keep.
there are miles to go before i sleep...
there are miles to go before i sleep...
|
|
|
|
|
You know in Windows xp or 2000, there is still the possibility of loosing data if you just yank out your flash drive, but to do it the proper way, you must go through a series of annoying dialogs. If I have the user enter their drive letter, for which the letter would be stored in the registry or something, Is there something I can access in Windows to programatically eject the drive without having to go through all those dialogs. For instance, simply run the app from the desktop with an invisible form that would exit once it had ejected (successfully) your drive. This would be very helpful to me, thanks!!!
|
|
|
|
|
There's nothing in the .NET FCL that will do this. You'll have to use the Win32 API DeviceIoCtl functions to get at the USB bus, enumerate it, find the device your looking for, then build the appropriate IOCTL message and send it to the Device Manager. There is very little information around to do this, so you'll have to do a bunch of your own research. A Managed C++ .DLL might help you out alot in this situation, saving you from P/Invoking the Device Management functions and structures.
Google for "USB C# DeviceIoControl" and you should come up with at least a few tidbits to get you started.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dialogs? Have you tried left-clicking the "safely remove hardware" icon in the system tray, which will popup a menu, and pick the device to unload? It should be that simple.
--
Joel Lucsy
|
|
|
|
|
Hi,
i need to find out how to read data from a .rar extension file and convert the data into a string format to that eventually be saved in to a SQL DB using C#.. i am not sure where to begin this task!?!?
ANY guidance as to where i should be looking or how i can get started with this task will be greatly appreciated..
Thanks guys...
Afzal Hassen
|
|
|
|
|
Are you trying to save the .rar file to SQL or the compressed files in the .rar file?
|
|
|
|
|
i'm trying to save the compressed files within the rar file.
is there a way that i can extract the files programmatically so that i can save the uncompressed files to the temp directory in windows where i can work with the file(s).
i've used winRar to extract the files but the files have no extension (i.e. .txt, .xls etc.) i have opened the files with notepad and they contain string records that i would like to process and then save in SQL srvr..
also, how do i make sure that when i want to process a file with no extension that it contains data that are of a string data type in order for me to sucessfully process the records..
Afzal Hassen
|
|
|
|
|
Hi!
I would like do deactivate the possibility to connect a usb-device like a usb-stick.
I have found the right regkey in the registry:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\USBSTOR]
But the problem is when I write a small program to change the regkey for me I do not have the permission do this even if I am an administrator.
My code looks like this:
RegWriteKey = RegWriteKey.OpenSubKey("SYSTEM\\CurrentControlSet\\Services\\USBSTOR");
RegWriteKey.SetValue("Start",4);
RegistryKey RegWriteKey = Registry.LocalMachine;
Any suggestion how to solve this?
|
|
|
|
|
You have to take into account that there might not have been a USB storage device attached before, as well as one having already been attached.
See How to disable the use of USB storage devices in Windows XP[^] on MSDN for an example.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I start an application out of my existing one, but I have a problem to put shell parameters out within the called app. How can I get the "args" ? In the void main ?
|
|
|
|
|
the correct definition for the main should be
static void main(string[] args)
{
...
}
so you can work with the args
|
|
|
|
|
hi,
I have 2 tables with a relationship and want to insert expense information from my asp.net form. PropertyCode is in my expense table in sql server acting as a foreign key. When inserting data do i have to code the fact that property code is >> Property.PropertyCode or something. Currently i cannot insert the data into my table. When working with only 1 table it works fine.
Please help
Regards
|
|
|
|
|
I need to create an object of a particular type. I will get the type information as a string.(For eg:string TypeToCreate="System.Drawing.Font"; ) during runtime.
With this information. How do I create an object?
|
|
|
|
|
Have a look a the MSDN docs for Activator.CreateInstance()
Ryan
|
|
|
|
|
That's exactly the way to go.
You just have to know the fully qualified type name of the class you want to create, otherwise the framework doesn't know which type to create.
For example, you can do this:
string typeToCreateName = "System.Drawing.Font, System.Drawing, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a";
Type typeToCreate = Type.GetType(typeToCreateName);
object o = Activator.CreateInstance(typeToCreate); There are two pitfalls, though:
First, determining the fully qualified type name can be a bit tricky.
Secondly, the type you want to create has to have a parameterless constructor. The example above will fail, because Font doesn't have such a constructor.
Mav
|
|
|
|
|
Try to extract a substring after the last "period" in the string (i.e., "Font"). If only one "type" information is returned in all situations, then simply create the object in a manner like this:
Font font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
However, if you expect objects of different types, the "type" of which can be extracted as above, then use a switch or "if-else if" statement, for example,
if(extractedString == "FONT")
Font font = new Font("Microsoft Sans Serif", 8, FontStyle.Regular);
else if (extractedString == "SOLIDBRUSH")
SolidBrush redBrush = new SolidBrush(Color.Red);
|
|
|
|
|
Not very dynamic is it? What if there are 500 possibilities of input...500 if/else if's?
|
|
|
|
|
Considering the fact that there are thousands of classes in the .NET Framework that you can create an instance of, are you sure you want to write an "if" statement for each one of them?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You are right, and I fully agree that one may not use this method if the output in the question is going to result into thousands of type of objects.
But, I guess in the practical life, and in a given application of a particular description, one would not be expecting too many types of objects where the above method may work. Moreover, one may have the "catch-all" default "else" statement in the end wherein a generic "object" type may perhaps be considered if at all it serves the purpose with or without casting it further.
Of course, I must admit in all fairness that it depends on the situation concerned, and that I had offered a simple practical solution thinking that only a few types of objects are going to be created.
|
|
|
|
|
hi all ,
I hav project(Win Form with c#)where i'am using sourcegrid2;in this grid i have combobox and i want refer the modification of this combobox; i don't know how i can refer this changement in order to call an event.
please can you help me?
thanks.
|
|
|
|
|
Hey!
I am connecting a CellPhone to the com1 and then i read this serial port from my program.
I know that the CellPhone is supose to give me alot of data all the time, but i oly get about 150 chars when i turn on the cellphone?
Even if the data is not decoded right it shold show all the data right?
BestRegards
jimmy
|
|
|
|
|
Hey!
I need advice!
I are building a Windows Library Control that will connect to CellPhone on the serial port(framework 2.0)
This unit will also share MemoryStreams to other units in the main program. My control will write anything that comes in on the serial port to this Memmory stream.
Problem:
When writing to a Memory strem in my control then the position ends on say 150. When i try to read from a unit that are listening on this Memory Stream, it will begin reading on position 150, and there is no data.
Do i have to use ReadByte and give the offsent and so on, and then manualy remove the readed bytes in the stream?
Best Regards
Jimmy
|
|
|
|
|
|
|