|
Hi, I recieve a chunk of XML as a string that i want to then deserialize, but none of the XmlSerializer.Deserialize overloads accept a string as parameter, mostly only streams, textreaders or xmlreaders. Surely there has to be a quick way to convert a string to one of those formats?
|
|
|
|
|
The streams live in System.IO, have a look there.
|
|
|
|
|
I don't think there's a smart way of doing this.
You could allocate a byte array, create a MemoryStream on it, and then write your string to the memory stream. Then you can deserialize from that.
|
|
|
|
|
Jon Hulatt wrote: I don't think there's a smart way of doing this.
System.IO.StringReader
|
|
|
|
|
Off the top of my head, you could try this:
public T FromString<T>(string serializedObject) where T : new()
{
XmlSerializer xmlSer = new XmlSerializer(typeof(T));
StringReader sr = new StringReader(serializedObject);
XmlTextReader stream = new XmlTextReader(sr);
try
{
T obj = (T)xmlSer.Deserialize(stream);
return obj;
}
catch(Exception ex)
{
}
finally
{
sr.Close();
stream.Close();
}
}
|
|
|
|
|
beautiful, thanks a lot
|
|
|
|
|
Glad to help.
|
|
|
|
|
Is there a way to create a simple button with no xp skins or anything? (like the buttons in minesweeper)?
I tried to disable UseVisualStyleBackColor but it still shows a blue rectangle on the button after it's been clicked.
|
|
|
|
|
You might find that one of the various FlatStyle options on Button does the job. Otherwise just draw the button yourself in an overridden OnPaint.
|
|
|
|
|
If you're using Visual Studio open up Program.cs and remove the line Application.EnableVisualStyles(); inside the Main function. This is what tells the app to use the Windows XP theme; doing this will remove the visual styles from every control in the app.
|
|
|
|
|
I have a web page with 3 date fields. One is required, the other 2 are optional.
These will be written to a database once the user clicks save.
Should I use the in-built customvalidator method? What about spaces?
Should I write a separate validator for dates using the dreaded REGEX?
Can I validate them all using FindControl in a ForEach loop (the id's all begin 'dt****')?
Any advice welcome.
Cheers
|
|
|
|
|
Use the custom validator - there's a method on the DateTime class called TryParse. This is a great way to check to see if the date is valid. Also, use a required validator on the date that is required.
|
|
|
|
|
Hey thanks for your willingness to help but ahm!! sorry that i'd have to disappiont you,but i really do not know how to implement the redo or undo actions
|
|
|
|
|
Well that's a shame, but who precisely was this aimed at? There are some excellent articles here on CP about implementing Undo/Redo - perhaps they might be of some assistance.
|
|
|
|
|
Hi
I have a application which creates a message queue and then recieves the message in it.when i create a test application it was working fine,now when i change this to a webservice its showing me an error which i logged in log file ,the error is as following queue doesnt exists or you do not have permission to perform the operation.Is it anything related with rights.
Actually the queue need to be created programmatically but it also not working.so i created it manually but also above error comes..why is it coming
Thanks in advance
Regards
DilipRam
|
|
|
|
|
The web service will be running under the heavily curtailed permissions of the ASPNET worker process. You need to grant access to this user for the queue.
|
|
|
|
|
Thanks for the reply.the user which i am using is the administrator of that machine.Is there i need to specifically do for the rights..if so can you pls give me the steps for that
Thanks in advance
Regards
DilipRam
|
|
|
|
|
Hi all,
I'm writing an intranet application using ASP.NET 2.0 and C#, and I have long gridviews (lots of rows, and the users don't want paging), but many users asked me to have a feature like "Freeze panes" in Excel : do you know a method to have the first row (table header) keep on top of the page (and top of the window) while scrolling in the page ?
Thanks !
Stéphane
|
|
|
|
|
Have a look at this article Scrolling Grid[^]
Tarakeshwar Reddy
MCP, CCIE Q(R&S)
There are two kinds of people, those who do the work and those who take the credit. Try to be in the first group; there is less competition there. - Indira Gandhi
|
|
|
|
|
Hi
I don't knot know if it is possible .
I want to get the output of a program from a command window into a textbox\Rich textbox.
For example:
When compiling in Visual Studio 6 using a command line option (no GUI) i get redirect the output into a text file .
1) Is it possible to get that input into a textbox?
2) If not how to display the ongoing progresses from the file?
Thanks
Have a nice Day
|
|
|
|
|
|
I am missing something here...
I red the page but couldn't get an answer...
please explain
Have a nice Day
|
|
|
|
|
liqnit wrote: am missing something here...
yes :P
liqnit wrote: I red the page but couldn't get an answer...
Seriously? Did you check out the members on the class? That link was to the main page for the class, the links at the bottom provide more information such as details on the Members of the class.
If you had "StandardOutput", "Start" and "GetProcesses" are pretty obvious.
GetProcesses will retrieve a list of all running processes from which you can get the one you want. Or you can use Start to run it if it's not already running.
Then StandardOutput gives you access to the output stream.
|
|
|
|
|
Thanks a lot
i guess i am not as good as i thought...
will definitely try this
thank you very much
Have a nice Day
|
|
|
|
|
No probs.
I'd highly recommend getting used to the MSDN as its very handy for checking out classes. If your using Visual Studio the intellisense can be invaluable as it can be used to see everything accessable on an object and provides comments.
|
|
|
|