|
1 - perhaps
2 - XML is XML, it doesn't matter where it came from. Do you mean how do you parse it in C# ? The XmlDocument class represents a DOM implimentation in .NET.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
You are right, but .Net provided way to serialize xml file so that you could send just the header over the net. My problem is how to deserialize and then parse it to the appropriate structure.
Nothing to say
|
|
|
|
|
Hi everybody!
I'm trying to get an HTMLInputElement using get getElementByID() or getElementByName() functions.
I need to get a certain button, but this button has no name or ID.
here is a part of the code (from the website)
<br />
<tr> <br />
<td class=td2 colspan=2> <br />
<input type=image src="http://***/sign-in.gif" border=0 alt="enter"> <br />
<a href="http://****number=9864"> <br />
<a href="http://*****name=find-b"> <br />
<img src="http://****/*-cancel.gif" border="0" alt="cancel"></a> <br />
<br />
</td><br />
I'm trying to get the "enter" input type (which is an image).
as you can see, there is no name/ID.
can anyone help me with this?
Thanks!!!
|
|
|
|
|
Post the sample code you are working with.
|
|
|
|
|
Hey
What I'm trying to do is to write a small app that will extend my (and my friends') library books (I'm a student) automatically.
so in the website I have the following code for the submit image(which the user can click on to... submit):
I'm using the following code to get the HTMLelement in C# so I will be able to click it:
mshtml.HTMLInputElement btn = (mshtml.HTMLInputElement)doc.getElementsByName(???);
as you can see, I don't know how to get the element, because I don't have an ID or a Name.
there must be a way to submit that page automatically, but I really have no clue.
Thanks Again!
|
|
|
|
|
Hello Community!
please don't worry about my spelling ^^ - i'm german
i created a datatable a datagrid and a datagridtablestyle
in the dtatgridtablestyle i defined a datagridtextboxcolumn and want to set the Autocomplete options of its TextBox. There are no faults, but there is NO autocomplete... why? i cannot imagine, because i do the same with a normal textbox and it works, but not with a textbox in a datagrid - so why?
|
|
|
|
|
Are u working on .net i mean that are you making a web application ?, if yes so i think u must use of this code, i wrote it for label .
<ASP:LABEL id="lblgroup" runat="server" font-bold="True" cssclass="contentTableGrey" text='<%# DataBinder.Eval(Container.DataItem, "GroupName").ToString() %>'>
GroupName is a column name of that tabel which you are binding to the datagrid.
let me know if it works .
|
|
|
|
|
|
i work with c#...
not asp.net
|
|
|
|
|
Hi,
I was wondering, If I add a namespace in my C# project (Windows) and If I use only one or two methods from a class of that namespace, then, when the project is being built, Do the compiler add whole namespace codes to my final release application or it just add the necessary useful methods from that namespace and keep the size of the application according to the usage of the methods. !!
|
|
|
|
|
None of the sutff you import from another namespace is actually compiled into your code. The stuff you use is only loaded into your process from the referenced assemblies when your code is executed. Those references are stored in your executable in what's called the "Imports Table". It tells the Loader what your code is going to need and where to get it from.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
HI Dave,
Thanks for your reply.
Actually the question came to my mind, because I wanted to use a method in my win application:
System.Web.HTTPUtility.URLEncode(...) and then I had to add a reference System.Web. Then I thought, Only for a simple method, I am adding a whole System.Web assembly, will that greatly increase the size of the application or not. Later I realized that either I will have to port the System.Web assembly with my application or the User of my application must have System.Web in his PC.
Now, How can I decide if I should choose "Copy to Output Directory" of a referenced assembly if the assembly is of a System.* NamesSpace ? Should I assume that all System.* namespaces are available in All Windows user's pc so that I dont need to port any System.* assembly ? (i.e. System.Web)
Regards,
Emran
|
|
|
|
|
bashiwala wrote: I am adding a whole System.Web assembly, will that greatly increase the size of the application or not
No, it won't. Any referenced code is not compiled into your app.
bashiwala wrote: Later I realized that either I will have to port the System.Web assembly with my application or the User of my application must have System.Web in his PC
You don't have to install it with your app. It's already part of the .NET Framework, which everyone who uses your app has to have installed before they can launch your .EXE.
bashiwala wrote: Now, How can I decide if I should choose "Copy to Output Directory" of a referenced assembly
If it's part of the .NET Framework, then you don't have to copy anything. If it's a custom written assembly, something you've put together, then you can select "Copy to Output Directory".
bashiwala wrote: Should I assume that all System.* namespaces are available in All Windows user's pc so that I dont need to port any System.* assembly
If it's in .NET Framework, then you can safely assume it's installed on the users PC. These[^] are all the classes that come in the .NET Framework that the users have to install.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi Dave,
Thanks a lot for your detailed reply. Now I have understood.
|
|
|
|
|
Hello,
It is my experience that, using Static Method makes life very easy. When I need a method call, I just simply call ClassName.MethodName().
But what is the key point I must be careful about using Static Method or Static Variable rather than Instance Method or Instance variable ?
Is Static method a problem for multi threaded application ? if so, then how come most of the System class has static method like, File.Exists(), File.ReadAllText(....), etc.. ?
Regards...
|
|
|
|
|
They have nothing to do with threading at all. It comes down to data encapsulation.
If you look at the FileInfo and File classes in the System.Io namespace, you'll see that they do the exact same things, only in slightly different ways. FileInfo is an instance implementation and File is static.
You can copy a file either of two ways. You can create an instance of a FileInfo object, then call the .CopyTo() method on it, passing in just the destination file name since the object already knows that it is the source path.
FileInfo myFile = new FileInfo("C:\\Test.txt");
myFile.CopyTo("D:\\TEST\\Test.txt");
Or you can use the static methods exposed by the File class, where you have to specify both the source and the destination paths:
File.Copy("C:\\Test.txt", "D:\\TEST\\Test.txt");
The FileInfo class encapsulates a single file where you can get properties on that file and tell it to delete, copy, or move itself. All of the methods will only work on that instance of the class.
The File class doesn't encapsulate anything. It requires you to specify which file it's going to work on with every single call you make.
You can read more about it here[^]. 'Cause if most of what you're writing is static methods, you're completely missing the point of object-oriented programming.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
If the method doesn't use any data from the instance of the class, it should be static. For example, the method File.Exists doesn't use any data other than the string that you send as a parameter.
Static methods are not a problem for multi-threaded applications.
A static variable is stored in the class rather than the instance of the class, so there is always one of the variable no matter if there are zero or a million instances of the class.
As all threads share the same variable, you have to use locking to make the use of a static variable thread safe.
---
b { font-weight: normal; }
|
|
|
|
|
Hi Guffa,
Thanks for your suggession. It is a bad news for me that you said I must use Locking of static variabls to make it thread safe. Now I will have to convert all my static variables to instance variables in my whole application as those variables are shared by threads. ((((((
If I use instance variable, then I dont need to lock as long as the instance is created within the thread, right ?
Is this locking required for only static variables ? or do I need to lock Static Methods too ?
I did not like to learn Lock chapter of C#. Is there any simple snippet you can show me to lock a variable ?
Thanks and regards
Emran.
|
|
|
|
|
Making the variables not static will not solve your problem. If your app is multi threaded, and the threads all access a variable that exists in a single instance, then you need to use locking. Static simply defines the fact that there is only one variable, but if you move the variable to an instance, and pass an instance between threads to access the variable, you've created a new problem ( passing a reference to the class ) and not solved the old one ( multi threads all hitting the same variable ).
bashiwala wrote: I did not like to learn Lock chapter of C
Why not ?
bashiwala wrote: Is there any simple snippet you can show me to lock a variable ?
Isn't it just the lock keyword and a block that does the work ?
bashiwala wrote: Is this locking required for only static variables ? or do I need to lock Static Methods too
Any code which changes a variable where that instance is shared across threads needs to be locked. Do you understand what the issue is ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Thanks a lot for detailed answer.
Ok, I tried to learn the lock but I did not understand from MSDN documentation.
Say for example, I have following variable, and method,
..............................................................
static int a = 8;
public static void myMethod(string myValue)
{
// do some change on XML.
}
..............................................................
Now, How can I just lock both of this variable and method ?
Will the following snuippet work ?
..........................................................
lock
{
static int a = 8;
}
lock
{
public static void myMethod(string myValue)
{
// do some change on XML.
}
}
................................................................
thanks and regards
Emran
|
|
|
|
|
No, you've got it wrong:
public static void myMethod(string myValue)
{
lock
{
// do some change on XML.
}
}
You're locking the portion of code that needs to be atomic ( it needs to all run before another thread tries to run any of it ).
You want to lock as much as you need, and as little as possible.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
Thank a loot for the help.
I have some const variables in my form like,
public const string dataPassword = "abcd";
public static string myValue = "1234";
This variable is shared by all threads simultaneously but this value is not changed by any of the thread. So, do you think I must use lock to protect this kind of variables ?
Thanks and regards
Emran
|
|
|
|
|
I'm not sure that you're getting the concept. The concept is, if two threads change a value, it's possible that data will be lost if one is half way through doing something and the other one steps in. If values are not being changed, no locking is required.
you would, however, be better off doing something like this:
public static string DataPassword { get { return "abcd"; } }
or at least mark then all readonly. static values can still be changed.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian,
thanks a lot.
Now I understood the concept.
|
|
|
|
|
Hi,
I am grateful for your previous guidances.
Would you please help me about a confusion.
In my Application, I have an XML file where only one thread WRITEs to this file. But multiple thread shares this file for READING. Do I need to apply LOCK in this case? Is there any chance of thread conflict while one thread is trying to write to the file and another thread is trying to read the file? (I thought confliction arises only when both of the threads are trying to write to the file).
Regards,
Emran
|
|
|
|