|
JoeRip wrote: I could instead derive my class from Song, and use a cast.
No, you couldn't. That would enable you to cast your object to Song, but not the other way.
JoeRip wrote: can both mySong.Artist and mySong.Artist.MaxLength yield values? If so, how do I implement this?
You can create a class for the Artist property, that has properties and an implicit conversion to string. That way you can both get the artist as a string and get properties from it:
public class LimitedString {
private string _value;
private int _maxLength;
publlic LimitedString(string value, int maxLength) {
_value = value;
_maxLength = maxLength;
}
public string Value { get{ return _value; } }
public int MaxLength { get { return _maxLength; } }
public static implicit operator string(LimitedString limited) {
return limited.Value;
}
}
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
JoeRip wrote: How do I "add" a property to the existing property of an object? Is that allowed syntactically?
Yes it is allowed.
JoeRip wrote: int x = myTune.Artist.MaxLength;
In song class Artist should be a property for a class which contains MaxLength property. See the below example
public class Song
{
public SongArtist Artist
{
get{}
set{}
}
public static void Main()
{
Song mySong = new Song();
int x = mySong.Artist.MaxLength;
}
}
public class SongArtist
{
public int MaxLength
{
get {}
set {}
}
}
|
|
|
|
|
I'm not quite following. What is happening in the Main() method of this class?
|
|
|
|
|
Creating object for Song class. In your example you are getting the object from GetSong() method. You can change that in your way
|
|
|
|
|
hi,
while using inheritance if we have two classess ie animal and bird -when do we craete a new object this way in main function
animal obj = new bird();
and when are the instances that we create an object to call a method::
i know that we do so wen we have to call a method from another class and to call a nonstatic function into a static function again we create an object.
otherthan these what are the other instances we do so ......
thanks
C#
|
|
|
|
|
1st learn to write proper question, then expect to get proper answer.
Regards
Chintan
www.visharadsoft.com
(I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
|
|
|
|
|
what are the times that we create an object to call a method::
i know that we do so wen we have to 1) call a method from another class and
2)to call a nonstatic function into a static function again we create an object.
otherthan these what are the other instances we do so ......
thanks
C#
|
|
|
|
|
how to get the innerHtml from iframe in C# ?
thanks ~
|
|
|
|
|
First you have to get document object for the IFRAME. Then Use innerHTML property to get it. See the following eg:
var TxtEditor = document.getElementById('IFrameId').contentWindow.document;
alert(TxtEditor.body.innerHTML)
|
|
|
|
|
to [N a v a n e e t h]:
thank you reply,but how did it in c# ?
|
|
|
|
|
Make a hidden textbox run at server. Get IFRAME value using javascript, and assign to this textbox. Since your hidden textbox is a server control, you have access to it from code behind.
|
|
|
|
|
//Make a hidden textbox run at server. Get IFRAME value using javascript, and assign to this textbox.
very good ~
but ,it also have problems ~
I have got the method that get value of iframe and assigned it to TextBox,
but when run the method to do this ? it required a Event,a suitable Event,the Iframe haven't got those Events,for example:onkeyup,onkeydwon,onchange,onpropertychange...,and in this section it haven't got a or the other control like to occur.
In other way , there's a user control with two properties:Text and Content.
when using the user control ,we just see the Content property is ok ,
the Content property's value is the iframe's innerHtml,Now i know how to get innerHtml in javascript ,but i don't know how to use it in codebehind ?!
the former said "..and assign to this textbox...",It request a suitable Event to do that , for there's no Form label,No button , only a button is in another page that use the user control,when it clicked we must show the user control's property ~ how ever , I do not like this method...
thank you very much !
|
|
|
|
|
Your question isn't clear enough!
Are you hosting a web control in a WinForm application written in C#?
Are you hosting a web control in a WPF application written in C#?
Are you using C# as a client side scripting language in the browser?
Are you writing an ASP.NET page in C# and want to see what the client has in the IFrame (nope, not possible, but it might still be what you are looking for so I included it)?
Are you accessing a web server from C# and want to extract the HTML from the web server response?
I am sure there are more possibilities, but this is what I could come up with as I typed, so you probably need to add some details on what you are doing and what you try to achieve.
|
|
|
|
|
in one word ,
In a UserControl ,How to get a iframe's innerHtml value and assign to its property ?
|
|
|
|
|
I used this code for connect to the database:
conStr = "Data Source=.\\SQLEXPRESS;AttachDbFilename=C:\\DB\\DBPerson.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
conn = new SqlConnection(conStr);
conn.Open();
How to move connection string to ApplicationConfig file? And how to use in my source code?
Best Regards...
|
|
|
|
|
I Solve my problem;
App.config:
<configuration>
<connectionstrings>
<add name="ConnectionString" connectionstring="Data Source=.\SQLEXPRESS;AttachDbFilename=C:\DB\DBPerson.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" providername="System.Data.SqlClient">
Source File:
string conStr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
conn = new SqlConnection(conStr);
conn.Open();
But my mistake is; I add App.config file in class library. So program not found the App.config file and return null value. App.config and exe must be in the same folder.
|
|
|
|
|
Hi All,
I am working on a project that host WebBrowser control using C#. Objecive of this project to automate
webBrowser. I have the element that, I want to be click automatically. Please Help!!
//Browser name = LPBrowser
mshtml.IHTMLDocument3 doc = (mshtml.IHTMLDocument3)this.LPBrowser.Document.DomDocument;
doc.getElementById("newlink").click(); //This click() method doesn't work me
A.Asif
|
|
|
|
|
I recall some issues with this as well, at least with the managed wrapper of the WebBrowser control (e.g. System.Windows.Forms.WebBrowser). I ended up using reflection and invoking it, and it seemed to work then. Something like this:
IHTMLElement2 element = doc.getElementById("newlink");
System.Reflection.MethodInfo clickMethod = element.GetType().GetMethod("click");
clickmethod.Invoke(element, new object[0]);
Try the above and see if it changes anything.
|
|
|
|
|
i had a video encoder which had a http server on it.
when opening the browser you can see the video stream in it.
i need to extract the video stream (mpeg4) so i can make some processing on it.
thnx
|
|
|
|
|
Hi,
I am developing a windows control library in C# and I have to display the serial number of some cards that are connected to the system. I have written the code in the windows control library class that retieves all the data. Now inorder to make it show properly in the properties box in Visual Studio when I am using the control I had to write another class that is a TypeConverter namely StringConverter.
so how does one take the serialnumber array which is just a string array in the windos control library class and give it to the StringConverter class?
Any help would be greatly appreciated
Thanks in advance
|
|
|
|
|
godspeed123 wrote: so how does one take the serialnumber array which is just a string array in the windos control library class and give it to the StringConverter class?
You need to specify some attributes for the property to get the collection editor on VS IDE. Take a loot at this article[^] which explains how to set the collection property, It's an ASP.NET example, but same can be used for windows library.
|
|
|
|
|
I need to consume a web servcie but when i try to access it through my code or through command prompt for generating proxy classes it gives me error
underlying connection was closed : unable to connect to remote server
If i send the same soaprequst to online webservice thorugh then i get the successful response back.
Please help me out.
neoms21
|
|
|
|
|
I'm working with upgrading a legacy system that has an archaic way of consuming web services.
I've played around with generating stub classes with the wsdl.exe utility that Microsoft provides for us, and I was wondering if anyone else uses this utility to do their job, and, if so, do you always leave that code unedited?
|
|
|
|
|
Yes and yes. If you edit your code and then do a re-gen, then you will lose your edits.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yes
Yes. Why would you edit the code?
|
|
|
|