|
Which serialization are you using? The System.Runtime.Serialization namespace elements or the System.Xml.Serialization namespace elements? The former does serialize references (as I mentioned before) but requires something to associate them with the original object. Since you don't have such a serialization manager, a copy of the class is deserialized, yes. There is not way to get an existing reference back since memory address shouldn't be stored (isn't durable), only to associate the data with existing objects. If you don't have something that will do that, all that can be returned is a copy of the class.
Again, read the link I sent you for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
How can i specify how many decimal places is displayed when i parse a double to a string??
Sorry, i'm still a beginner with c#!
|
|
|
|
|
Fairly simple:
double d = 2.12165464578784545;
string s = d.ToString("#.##");
Tomas Rampas
------------------------------
Systems analyst, MCSD
rampas(at)gedas(dot)cz
http://www.gedas.com/
------------------------------
|
|
|
|
|
If you want to maintain a precision of 2, use "#.00" instead of "#.##" so that 0 will be used when no number exits in that position.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Is there a way to change a row's color in a datagrid? I've got a datagrid where i would like to change every 3rd row's color. Is this possible???
|
|
|
|
|
I have a article about How to change a back color of one cell based on its value.
http://www.codeproject.com/csharp/custom_datagridcolumnstyl.asp[^]
There are sone other articles in this site which I think about changing the color of entire row, use the serach engine at top of this page.
Mazy
"Art is life, life is life, but to lead life artistically is the art of life." - Peter Altenberg
|
|
|
|
|
Thnxs for your answer, I got it to change every 3rd row. But now there is a different problem, the instant i scroll down on the datagrid the colors get messed up or changes to one color. Do you know what this problem could be?
|
|
|
|
|
Don't worry, i got the problem, it was pretty stupid. Thnxs for the help.
|
|
|
|
|
I have a datatable i will add some records to it..
I want this datatable to update directly to database. Using DataSets and DataAdapter
Please let me know abt this new
Praveen C
|
|
|
|
|
SqlDataAdapter.Update() method.
Mazy
"Art is life, life is life, but to lead life artistically is the art of life." - Peter Altenberg
|
|
|
|
|
You need to use a DataAdapter (for this, I'll assume a SqlDataAdapter and related classes) with SelectCommand , InsertCommand , UpdateCommand , and DeleteCommand properties assigned. If you use a simple SELECT query (i.e., no JOINs or nested SELECTs) you can use a SqlCommandBuilder to generate the other 3 SqlCommand properties from the SqlCommand for the SqlDataAdapter.SelectCommand property. These commands must also be parameterized.
You can also use the VS.NET designers to create the SqlDataAdapter and all the SqlCommand s for you. You can drag a DataSet (which can be strongly-typed) or SqlDataAdapter from the "Data" tab of your toolbox when a component is open in the designer. Play around with this, though I recommend you examine the code that is generated in the source file to understand what it going on.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
hi
i want to know how can i get and set the graphics card settings using c# and possibly GDI+ or d3d.
also can anyone tell me how can i run a win form app in full screen mode
sid
|
|
|
|
|
Anonymous wrote:
i want to know how can i get and set the graphics card settings using c#
Maybe this article helps:
http://codeproject.com/csharp/wmi.asp[^]
Mazy
"Art is life, life is life, but to lead life artistically is the art of life." - Peter Altenberg
|
|
|
|
|
Hi All,
is it possible to implement a drag & drop interface in C#. And if so can anyone point me to a tutorial or give me some tips. I need to be able to drap an item from a list box and drop it on a button which will envoke the click action of the button on the item dragged from the list box. Any takers? ,
Regards,
John
|
|
|
|
|
Take a look at "AllowDrop", "DragDrop", "DragEnter", "DragLeave", and "DragOver". They are part of System.Windows.Forms.Control, and so are inherited by all the visible controls on a form.
John
"You said a whole sentence with no words in it, and I understood you!" -- my wife as she cries about slowly becoming a geek.
|
|
|
|
|
See the Control.DoDragDrop method for information and an example.
Basically, you pack information into an IDataObject impementation (like the DataObject class provided in the base class library) and identity it with a simple string known as a clipboard format (this is covered in more details in the Platform SDK, though THAT IDataObject is different, but the concepts are the same). Handle the DragOver and DragDrop events on your button such that you check for the existence of this clipboard format:
private void button_DragOver(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent("MyCustomFormat") &&
(e.AllowedEffect & DragDropEffects.Link) != 0)
e.Effect = DragDropEffects.Link;
}
private void button_DragDrop(object sender, DragEventArgs e)
{
if ((e.AllowedEffect & DragDropEffects.Link) != 0)
{
object o = e.Data.GetData("MyCustomFormat");
if (o != null)
{
this.currentListItem = o;
this.button_Click(sender, EventArgs.Empty);
}
}
}
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thats great. Thanks for the help. I will be giving it a go over the next few days so hopefully wont have any problems,
Regards,
John
|
|
|
|
|
Hey
I am building a Server/Client program that sends object between them.
I have made a Client class that hold al the information the server need to have about the client. This clas Client includes socket.
Maby its stupid to have the socket to the client in this class but right now i am only testing things to se what i can send and how.
Anyway, I need to Serializ this class(client), but it says that socket cant be Serialized, is there any way to get around this?
//SnowJi,
|
|
|
|
|
First of all, you shouldn't serialize the Socket itself, but perhaps information about the socket. To be serializable, a class (the class you instantiate, not any base classes) must be attributed with SerializableAttribute . If you want to control serialization, implement the ISerializable interface. See the documentation for the ISerializable interface in the .NET Framework SDK for more information, such as implementing the special constructor used for deserializing information. By implementing this interface, you could just serializing certain properties about the socket. See Serializing Objects[^] in MSDN for more information.
Second, you should take a look at .NET Remoting. It is the de facto way in .NET to talk to different AppDomain s (contexts in which applications run, which obviously your client and server are in different contexts). It takes care serialization (so long as you follow the same serialization rules I mentioned above) and transportation across TCP, HTTP, or any custom transport channel using SOAP, binary, or any custom serialization formatter you want. See .NET Remoting Overview[^] for more information about remoting.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I need to download HTML pages from a website. These pages require username/password access which I DO have. The problem is, the website sets a persistent cookie in my Cookies folder and it's encrypted, so I can't read it's content.
How can I automate the download of these pages but not through internet explorer? In other words, how can I make WebClient/HttpWebRequest read the persistent cookie in my local folder?
If I can't do that, then how do I do it?!
Thanks.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
First of all, the cookie should NOT have the password contained within it. This is very insecure. The web site should authenticate the credentials in whatever way is fit (say, BASIC authentication of HTTPS) and return a ticket that signifies that the credentials have been authenticated. This is the underlying concept of authentication.
Second, if you have the username and password, you could make the call to the web server to get the ticket and that should return you the cookie. In order to accept the cookie, though, your HttpWebRequest.CookieContainer must be initialized:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://www.codeproject.com");
request.CookieContainer = new CookieContainer();
HttpWebResponse response = (HttpWebResponse)request.GetResponse(); This example if very basic, but you can find more information in the documentation for HttpWebRequest.CookieContainer .
Additionally, you can also pass the username and password to the initial request to avoid making several requests. You'll still need the initialized CookieContainer to store the response cookies (and use that over for every request and response), but you can put the username, password, and domain in a NetworkCredential and assign that to the HttpWebRequest.Credentials property before getting the response (which commits the request). See the documentation for the HttpWebRequest.Credentials property in the .NET Framework SDK for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm going nuts
Nothing is working. The URL I'm trying to get is the following:
http://search-completed.ebay.com/search/search.dll?GetResult&sosortorder=2&sacategory=29278
It retrieves certain completed auctions from eBay.
This URL however, results in a page that says: you have to sign in. I get the source of this page, I see that it gets a posting (username/password) from you, and redirects you to the original page you were requesting. I post this data, it gives me a Redirect Error, although I have HttpWebRequest.AllowAutoRedirect set to true. I also tried KeepAlive = true/false. No luck.
So, I try posting my username/password to http://signin.ebay.com/aw-cgi/eBayISAPI.dll which is the sign in page, and getting the cookies returned. It gives me a Cookie Error page, where it says my browser cannot accept cookies, although I did set CookieContainer of my HttpWebRequest.
What can I do?!!! If anyone wants to try:
username = booksbysammy
password = stupiddog
Thank you very much.
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
Okay, there's a few things I have to mention. When using form-based authentication, the HttpWebRequest.Credentials won't suffice. You either have to POST or GET data to the form action as you've discovered. I just wanted to mention this to be clear.
The problem looks like it doesn't recognize your user agent (the browser name and info). Fortunately, you can trick into thinking another browser is making a request (i.e., one that supports cookies) by the HttpWebRequest.UserAgent to something like "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" and it will think Internet Explorer 6.0 on Windows XP is making the request. This error might be making such assumptions because it's quicker than setting a cookie and checking for it in the next request (which requires making a request and getting a response twice). It's worth a try.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Heath Stewart wrote:
When using form-based authentication, the HttpWebRequest.Credentials won't suffice.
I'm sorry, I don't get you there. I don't use HttpWebRequest.Credentials at all in my code. Am I doing something wrong?
Heath Stewart wrote:
Fortunately, you can trick into thinking another browser is making a request (i.e., one that supports cookies) by the HttpWebRequest.UserAgent to something like "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"...
I already did this, no luck
Sammy
"A good friend, is like a good book: the inside is better than the cover..."
|
|
|
|
|
I was saying that when you use form-based authentication (like putting your credentials in a form online) the Credentials property won't work to pass your username and password. That only works for authentication protocols like BASIC or NTLM (and this is extensible, too).
Did you set the UserAgent before making the request to the ISAPI extension DLL on eBay to authenticate your credentials? Also, you should'be set an instance of the CookieContainer on the HttpWebRequest.CookieContainer property, too, but I believe you said you already did this.
Are you saving the request the web server returns? What exactly is the error message?
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|