|
Hi, I've recently discovered the beauty of serialization and my problem is that I want to access the parent member set by the serialization and get the value, this upon creation of course. I'm using three classes, the Parent-class, the Children-class and the ChildCollection-class. Now, I want the childrens created to have the same last name as the parent. When I try to use base.value it's null/empty. Anyone have any suggestions on how to solve this?
Parent class
<br />
[Serializable()]<br />
public class Parent<br />
{<br />
private string _strName;<br />
private string _strLastName;<br />
private ChildCollection m_Children;<br />
<br />
[XmlAttribute("name")]<br />
public string Name<br />
{<br />
get { return _strName; }<br />
set { _strName = value; }<br />
}<br />
<br />
[XmlAttribute("lastName")]<br />
public string LastName<br />
{<br />
get { return _strLastName; }<br />
set { _strLastName= value; }<br />
}<br />
<br />
public Parent()<br />
{<br />
m_Children = new ChildCollection();<br />
}<br />
}
The ChildCollection class
<br />
public class ChildCollection : CollectionBase<br />
{<br />
public Child this[int index]<br />
{<br />
get { return (Child)this.List[index]; }<br />
set { this.List[index] = value; }<br />
}<br />
<br />
public void Add(Child child)<br />
{<br />
this.List.Add(child);<br />
}<br />
<br />
public void Add(string name, string lastName)<br />
{<br />
this.Add(new Child(name, lastname));<br />
}<br />
The Child class
<br />
[Serializable()]<br />
public class Child : Parent<br />
{<br />
private string _strLastName;<br />
<br />
[XmlAttribute("name")]<br />
public new string Name<br />
{<br />
get { return _strName; }<br />
set { _strName = value; }<br />
}<br />
<br />
[XmlAttribute("lastName")]<br />
public new string LastName<br />
{<br />
get { return _strLastName; }<br />
set { _strLastName = base.value; }<br />
}<br />
<br />
public Child() {}<br />
}<br />
|
|
|
|
|
What you are doing doesn't really make sense. You don't have a public property for your Childred collection on your Parent class. You are defining Name and Lastname again on your child class when they are already defined in your Parent class that you are inherting from. If you are trying to serialize your parent class the child collection would be null since there is no public property.
I guess I would take a step back and think through what you are trying to accomplish with this design. Normally your base class would have public properties that would be shared with all children. Then the children would introduce new properties.
Now if your Parent class was in interface instead, then you would have to implement all of the public properties.
Anyway, I am not sure if any of that is helpful.
Ben
|
|
|
|
|
It was just to be clear with things, I do know I do not have to declare the same properties again, and the private variables should be protected. But you do understand the concept? Or else, don't bother answer. Well the real class have other properties, this is just and examble!
|
|
|
|
|
hi friends
Now i am developing one site.i need to set alert frequency,it use to send the
message through mail(here option is daily,weekly,monthly) to client..
if u have any doubt plz refer this link:
http://www.99acres.com[^]
how can i achieve this.plz send me code and related links;
regards
saravanan
|
|
|
|
|
You may need a Windows service to poll and send an email.
|
|
|
|
|
Hello
After log in to the application the textbox to disply the name of the person log in the application(automatically).And after selecting the date from the calender the label to display trhe week number(automatically).on the next web page
BoipeloMothusi
|
|
|
|
|
Was there a question in there or is it just me?
|
|
|
|
|
Yes, but you have to use your decoder ring from Ovaltine.
|
|
|
|
|
After log in to the system the textbox on the next webpage to display the name of the person log on to the system
OlgaM
|
|
|
|
|
Create a DTO UserProfile which contains getter and setter properties for all user related information
In the login page, Create an instance of UserProfile and set all needed fileds and store it session(that helps to use userprofile through out the application.
Write a user control to show username and date. and use it in all the pages
Regards,
Sylvester G
Senior Software Engineer
Xoriant Solutions
sylvester_g_m@yahoo.com
Score it if you like my post
|
|
|
|
|
Sir/madam,
I was trying to run the website and I got the following error.
Unable to connect to the Visual Studio Local Host web Server.
Please help.
Thanks and Regards
Pankaj
|
|
|
|
|
Where you trying to run the website through Visual Studio? Sounds like the built in web server isn't installed/configured/running or something.
|
|
|
|
|
Hi all,
I want to design an application to handle a certification exam for some people using asp.net 2.0.First i do created a login page/register to get the information of the candidate going to appear the exam.After validateing the credentials i want to let the exam seeker to apper a page something like
http://www.4futureengineers.com/tests/csharpetest.htm[^][^]
i want to keep both prev and next buttons,a button to bookmark the question to refer latter and a submit button to provide the result......same as Microsoft certification exams does.
i want to expose single question at a time.
when i am clicking next i want to store the answer...and update it in the database....Plz send approprete code or URLsto do.
|
|
|
|
|
Hi, I have the following problem;
I want to set a background-image for my masterpage. If i do the following, the background-image shows upp as it should, no problem here.
But if I take out the style tag and put it in my css file, it doesnt work..
website
|
- Images (folder)
--- bg_tile.gif
|
- Styles (folder)
--- masterpagelayout.css
|
- Masterpage.master
-----CSS file------
body
{
background-image:url('Images\bg_tile.gif');
background-repeat:repeat;
margin: 10px;
padding: 0;
}
------Code---------
<title>Untitled Page
Anyone have any idea why? I have tried changing the url in the css file without any luck. But if I for example add background-color: #330033 to the body tag in the css file it shows on the page..
|
|
|
|
|
The url in the style sheet is relative to the location of the style sheet file, not the page where it's used.
Also, a virtual path uses slash, not backslash.
background-image: url(../Images/bg_tile.gif);
---
single minded; short sighted; long gone;
|
|
|
|
|
Beat me to it
|
|
|
|
|
The CSS url() statement is relative to the CSS file, not the page referencing it. So you would in fact want:
background-image:url('../Images/bg_tile.gif');
|
|
|
|
|
Thanks alot, the ../ made it all work
|
|
|
|
|
Hi
What is the code to add enrty in the textboxes to the data grid,when you you click the buitton.
BoipeloMothusi
|
|
|
|
|
plz let me know is textboxes are populated in the gird or present some where in the webpage..!!
|
|
|
|
|
Hi,
Can you please help me
What is the code to add the information typed in the textbox to the datagrid,when clicking Add Entry button?
Boipelo Mothusi
|
|
|
|
|
|
How to delete a row in a gridview
nzibi
|
|
|
|
|
|
Hi,
Can you please help me
What is the code to add the information typed in the textbox to the datagrid,when clicking Add Entry button?
|
|
|
|