|
Therefore, you need to not send HTML mail if you want it to work in outlook, right ?
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.
|
|
|
|
|
I have a default.aspx inheriting a site.master. I placed a login usercontrol inside the default.aspx like so:
<%@ Register TagPrefix="uc" TagName="ctrlLogin" Src="ctrlLogin.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" Runat="Server">
<uc:ctrlLogin id="controlLogin" runat="server"></uc:ctrlLogin>
</asp:Content>
To reference functions in the globalLogin, the login usercontrol ctrlLogin.ascx.cs has:
globalLogin login = (globalLogin)this.NamingContainer;
login.whatever()
This generates the error:
System.InvalidCastException: Unable to cast object of type 'System.Web.UI.WebControls.ContentPlaceHolder' to type 'ProjectName.globalLogin'.
Can anybody help me out and let me know what I am doing wrong? Thanks.
|
|
|
|
|
Hi,
Am creating a page that uses anthem control on .NET, and every thing works fine until i need a popup page to appear i click on the button but nothing happens i right click on it then click open the pop up appears.
I think the issue that the whole page needs to go to server to open this page because when i right click the bar status at the bottom of the Browser appears. I replace the anthem control with asp one same problem could any one help me.
|
|
|
|
|
I have no idea what you're asking, but suspect it's about a third party library ( so, ask them ) and to do with ASP.NET ( so, ask in the ASP.NET forum if you ask here )
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.
|
|
|
|
|
The question below got me thinking.
Is there a reason why ToString() has been implemented in .Net as a method and not a property?
More importantly, is there a good reason"
___________________________________________
.\\axxx
(That's an 'M')
|
|
|
|
|
The ToString method is generally considered as a framework-wide helper to convert objects to their string representations. The keyword in that sentence is, again, convert; conversions generally take place in methods, not getters. Properties are meant for attributes of an object, not their representations in other types.
|
|
|
|
|
I can't think of any. A public virtual get-only property ToString would compile to public virtual get_ToString(), the name is the only thing that's actually different from the way it is now.
So I think it's about more religious things such as "properties should not throw exceptions" and "properties should not do a lot of work"
|
|
|
|
|
Another reason could be that ToString() can be overloaded with additional parameters. For example, it is overloaded for double, where you can pass in a format string.
ToString as the name of a property also doesn't make sense, because it indicates an action. As a property, it should have been called String or something, which may be confusing.
I guess it's also something inherited from Java, where it is called toString() .
|
|
|
|
|
Martijn Boeker wrote: I guess it's also something inherited from Java, where it is called toString() .
Not quite. Java don't do no stinking properties! It has variables and methods. The closest thing to a property I can think of is length on an array.
Martijn Boeker wrote: Another reason could be that ToString() can be overloaded with additional parameters. For example, it is overloaded for double, where you can pass in a format string.
This is the correctest answer ! The two arguments are that any action must be a method and nothing should be changed by a getter.
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Nagy Vilmos wrote: correctest
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Good isn't it!
For a real brain weep, on the radio this morning someone said '...more better...'
Panic, Chaos, Destruction.
My work here is done.
|
|
|
|
|
Nagy Vilmos wrote: Java don't do no stinking properties!
How is this relevant? It just seems that C# copied the toString() method from Java and they somehow decided to leave it as a method.
Nagy Vilmos wrote: nothing should be changed by a getter
ToString() normally does not change the state of the object.
Anyway, this is not even an argument because a property getter can change the state of an object. For example, the property can be lazy loaded, like a property getter that is mapped in NHibernate.
Nagy Vilmos wrote: any action must be a method
The action is "Get a string representation of this object". This 'action' sounds like it could be represented by either a property getter or a method, it doesn't really matter.
In general, you cannot judge if something should be a property by the amount of work it does or if it changes the state of an object. A property is part of the class interface and does not reveal any information about how it is implemented. I suppose the only rule is that if you set a property to a certain value, you expect to get the same value back when you call the property getter.
|
|
|
|
|
Yes, a type may define overloads of ToString that require parameters (see int for example), properties can't be overloaded.
|
|
|
|
|
On the following sample code I get the error:
Operator `+' cannot be applied to operands of type `string' and `method group'(CS0019)]
protected virtual void OnButton7Clicked (object sender, System.EventArgs e)
{
string str1 = ("This is number " + x.ToString);
label1.Text = str1;
x+=1;
}
Any feedback would be appreciated. I am a VB.Net Programmer mowing to C#
|
|
|
|
|
tsqlmand wrote: string str1 = ("This is number " + x.ToString());
You missed out those brackets.
|
|
|
|
|
Thank you both. I had some evening blindness I Guess.
|
|
|
|
|
|
Without trying to execute the code, did you add parenthesis to ToString method: x.ToString() ?
Uri
|
|
|
|
|
You need to understand that in C#, you must use parenthsesis when using a method.
No parenthesis is required for properties.
You are tring to concatenate the value of integer variable x with a string, in the process you tried to convert the variable x to string using ToString method, but missed out on the parenthesis.
Note that ToString() is a method and not a property, so use ToString() instead.
|
|
|
|
|
Hi,
I am developing program to connect to the windows server 2003.
i want to copy some folders from server PC to client PC through my program. if i do this without program then windows pops up for username and password to connect to the server. But in my program how can i handle pop up or how can i connect to the server?
Thanks for reply.
yogesh
|
|
|
|
|
public string RemoteConnection(string targethost, string targetusername, string targetpassword)
{
StringBuilder result = new StringBuilder();
try
{
ConnectionOptions Conn = new ConnectionOptions();
if (targethost != Environment.MachineName) //WMI errors if creds given for localhost
{
Conn.Username = targetusername; //can be null
Conn.Password = targetpassword; //can be null
}
ManagementScope scope = new ManagementScope(targethost , Conn);
scope.Connect();
return result.ToString();
}
catch
{
return "fail";
}
}
yogesh
|
|
|
|
|
helo yogesh_softworld123
I can't find ConnectionOptions's definition, what's its Namespace ?
thanks a lot~
|
|
|
|
|
Hello,
Here's what I'm trying to do. I need to create a toolbar that will post username/password to a webpage, get a cookie as response, and save that cookie so that the browser has access to it. Right now, I am able to send a post and save the response with the following code:
private bool getCookie()
{
HttpWebRequest request;
try
{
string dest = "http://" + ip;
string p = "username=un&password=pass";
MessageBox.Show("Sending a request to: " + dest + " with creds: " + p);
request = (HttpWebRequest)WebRequest.Create(dest);
request.CookieContainer = cookieJar;
request.Credentials = CredentialCache.DefaultCredentials;
request.Method = "POST";
Byte[] byte1 = Encoding.ASCII.GetBytes(p);
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = byte1.Length;
Stream newStream = request.GetRequestStream();
newStream.Write(byte1, 0, byte1.Length);
newStream.Close();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
MessageBox.Show("Please ensure correct IP address.");
return false;
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
if (response.Headers["Set-Cookie"] == null)
return false;
string[] cParams = response.Headers["Set-Cookie"].Split('=');
string cName = cParams[0];
string cValue = cParams[1];
MessageBox.Show("Cookie name: " + cName + " Value: " + cValue);
myCookie = new Cookie(cName, cValue);
myCookie.Expires = DateTime.Now.AddHours(1);
response.Cookies.Add(myCookie);
response.Close();
return r;
}
However, I do not think the cookie is being saved. Also, I don't really want to have it expire in 1 hour, I would prefer it to expire at end of session, but not sure how. I want the browser to have access to the cookie for future navigation. Essentially the toolbar logs the user in and performs the first query to the system. Future queries are likely to be done thru the web interface. I tried using an HttpCookie, but I couldn't pass it to Cookies.Add() since it wants a Cookie and not HttpCookie. I tried manually adding the cookie to the header of navigate/2 by:
string h = "Cookie: name=value";
Object header = h;
navigate/2(url, null, null, null, header);
and it does add to the header, but the page does not log me in :/
Any help appreciated!
Mike
FREE 28 player online game @ http://www.1483online.com where the community drives enhancements to the game!
|
|
|
|
|
I have a delete button on my windows form and a data grid view with a check box column. Now what I want is to let the user select values he wants to delete by checking the check boxes. Now when he clicks the Delete button not only the selected values be deleted from the grid view but also be deleted from the database.
|
|
|
|
|
Loop through the rows in the datagridview
identify the record that is checked
Delete it from the database
reload the DGV
Loop through the rows in the datagridview in REVERSE
identify the record that is checked
Delete it from the database
Delete the row from table/list supporting the DGV
Never underestimate the power of human stupidity
RAH
|
|
|
|