|
[Serializable]
public class SpecialOccasionsItem
{
private int id;
private string mediafile;
public int ID
{
get{return id;}
set{ id = value;}
}
public string MediaFile
{
get {return mediafile;}
set{mediafile = value;}
}
public SpecialOccasionsItem()
{}
public SpecialOccasionsItem(int itemID, string mediaFile)
{
mediafile = mediaFile;
id = itemID;
}
}
in the webservice there is the methed
[WebMethod]
public List<SpecialOccasionsItem> GetSpecialOccasionsCollection()
{
List<SpecialOccasionsItem> il = new List<SpecialOccasionsItem>();
return il;
}
In the application that requests this web methed
*I get a can't cast exception*
public List<SpecialOccasionsItem> GetSpecialOccasionsCollection()
{
try
{
List<SpecialOccasionsItem> il = new List<SpecialOccasionsItem>();
Array Gsoc = se.GetSpecialOccasionsCollection();
for (int i = 0; i < Gsoc.Length; i++)
{
il.Add((SpecialOccasionsItem)Gsoc.GetValue(i));
}
return il;
}
catch { }
}
|
|
|
|
|
AFAIK, it is not possible to pass the custom object by using this attribute "Serializable". In our project, we used to pass the custom object from web application to web service. (there is one debate about "passing custom object vs passing individual parameter") In order to do that, we have to put XML Seriablzable attribute (as same as the one generate for Proxy Class) in custom class instead of "[Serializable] "
F16I wrote: In the application that requests this web methed
*I get a can't cast exception*
It is probably because of one auto-generated class in your proxy class..
Please check your proxy class of your webservice.. I believe that there are one class like that in it..
public class SpecialOccasionsItem<br />
{ <br />
public int ID;<br />
public string MediaFile;<br />
.... <br />
}
If I'm right, please comment this class.. copy the attributes from this class. and paste them at the top of your class..
Let me know if you are not clear...
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Array Gsoc = se.GetSpecialOccasionsCollection();
Doesn't this web service call return a List<specialoccasionsitem>? Why are you trying to assign it to an array?
Where is the InvalidCastException being thrown? Is it this line?
|
|
|
|
|
Well I got it to work,
it look like the auto-generated webservice created a class for my custom class
|
|
|
|
|
How to upload an image using C# 2003?? Please give me.. code for reference...
who i am? i am....
|
|
|
|
|
|
How to do this.
When user stores something in clipboard, my program to store that in a text file.
Please help.
Thanks.
C#
|
|
|
|
|
|
Thanks, but I don't want to check every second the clipboard.
That should be something like an event, when the clipboard content is changed, then the program to store the data somewhere.
C#
|
|
|
|
|
Hi,
the clipboard is a unique system-wide resource; it is accessible through the
Clipboard class which has several methods, but no properties and no events.
other unique resources (such as keyboard and mouse) are associated to a single
process and a single control at a time, clipboard is different.
SO the only solution would be to periodically poll it, check for text,
compare with previous text, etc.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
|
plz how can i read a string from a txt file then insert it in a database table using C# in visualstudio2005 ?
|
|
|
|
|
Try the following projects...
To read a file.
Insert into a database
Above are two code projects that were quite easy to search for. If you combine the concepts and examples from the two projects, you'll get the answer you need. If you had been more specific about a single problem, you probably would have got a source code answer for that problem.
Hogan
|
|
|
|
|
Hi,
you can read the text in bytes and then insert the bytes (search on google:write blobs in database) in database.
-- modified at 5:19 Thursday 23rd August, 2007
|
|
|
|
|
I am planning on making the dialog for the custom settings for a software.
On the dialog, on the vertical left side, there would be the listbox showing "password", "Wired", "RF", "Save Folder Location" stuff like that on the list box.
Now, in the group box, I would have the different components showing in the groupbox on the right side, depending on the selected item on the listbox.
Should I use groupbox[], and the index in [] be based on listbox selected index?
Should I call a method, based on the listbox name so it would dispose the existing group box and generate a new one?
I hope this is not confusing...
|
|
|
|
|
I'd create a user control that displays the properties of each aspect of your software. Then, swap in (make visible, set position) the appropruate panel on the right of the list box when the selection changes. You'll need to prevent a selection change if validation of the currently displayed panel fails.
/ravi
|
|
|
|
|
Hi,
the easiest approach for showing a lot of groupable settings, is by using a
Tab Control with several TabPages. The tabs would be organized horizontally then.
If you really want it with the tabs to the left, I suggest you build your own
Tab Control look-alike.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Or you could wire up a ListBox and a TabControl to solve this problem.
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.tabControl1.Region = new Region(new RectangleF(this.tabPage1.Left, this.tabPage1.Top, this.tabPage1.Width, this.tabPage1.Height));
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (((ListBox)sender).SelectedIndex == 0)
tabControl1.SelectTab(0);
else
tabControl1.SelectTab(1);
}
}
I'm using the region setting to hide the TabPage selections from the UI, so the ListBox can be used to control the TabPage display. Obviously, you migth have more than two TabPages, so you'd need to change the listBox1_SelectedIndexChanged() event to control your TabPages as you need.
I hope that helps.
|
|
|
|
|
I don't know if this is the right section to ask this question
but if someone have some idea i appriciate his help
when i do the wizard step to do the replication this error occur always:
The operation could not be performed because OLE DB provider "SQLNCLI" for linked server "REPLLINK_TELECOPLUS519346055_DATETIMEDA579057684_PUB5-1837106822_EMPTYFORRE236221469" was unable to begin a distributed transaction.<br />
Changed database context to 'emptyForRep'.<br />
OLE DB provider "SQLNCLI" for linked server "REPLLINK_TELECOPLUS519346055_DATETIMEDA579057684_PUB5-1837106822_EMPTYFORRE236221469" returned message "The partner transaction manager has disabled its support for remote/network transactions.". (Microsoft SQL Server, Error: 7391)
I'm re-sorry to ask this question in this section
Assaf
|
|
|
|
|
IN VB.NET I use to write :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click,Button2.Click, Button3.Click
and any code inside
End Sub
I use this way if i want many button to do the same thing
My Question is how i can do like this in C#
it's urgent for me
Thanks in advance
Assaf
|
|
|
|
|
One way would be:
Button1.Click += new System.EventHandler(this.Buttion1_Click);
Button2.Click += new System.EventHandler(this.Buttion1_Click);
Button3.Click += new System.EventHandler(this.Buttion1_Click);
Hope that helps.
Ben
|
|
|
|
|
Where I should this snipet of code ???
Assaf
|
|
|
|
|
Form load would be a good place to put that snipet of code. That way it only runs once. If the code were to run twice you would get multiple calls to your button click event which would be very bad.
Ben
|
|
|
|
|
I pure GUI way would be to go to your form. Click on Button1 then go to the properties window. Click the lighting bolt this shows you the events for the button. Select the correct button click event. Repeat for other buttons.
Hope that helps.
Ben
|
|
|
|
|
I didn't get the methode of inserting code
and it not work if i put them in load form
but i try the second method to for the clickevent in the properties and it work
thank a lot
Assaf
|
|
|
|