A
Aaron Bull
G'day All,
Looking at the documentation, it looks like what I'm trying to do is
possible, but I can't get it to work. Any suggestions would be greatful.
I'm trying to make a server control, so the calling aspx code will look
similar to this
<ab:MyControl runat="server" id="blah" >
<FirstName>Jimbob</FirstName>
<LastName>McGoo</LastName>
</ab:MyControl>
Where firstname and lastname are properties of type string, of the MyControl
Class.
I have the simple class inherited from control, i.e
[ParseChildrenAttribute(true)]
public class MyControl : Control
{
private string m_firstName = string.Empty;
private string m_lastName = string.Empty;
public string FirstName
{
get { return m_firstName ; }
set { m_firstName = value;}
}
public string LastName
{
get { return m_lastName ; }
set { m_lastName = value;}
}
public void Control_Load(object sender, EventArgs e)
{
Response.Write( m_firstName + " " + m_lastName);
}
public MyPlaceHolder() : base()
{
this.Load += new EventHandler(Control_Load);
}
When I try to run the code, i get the error "Literal content ('Jimbob') is
not allowed within a 'System.String'."
Cheers
Aaron
Looking at the documentation, it looks like what I'm trying to do is
possible, but I can't get it to work. Any suggestions would be greatful.
I'm trying to make a server control, so the calling aspx code will look
similar to this
<ab:MyControl runat="server" id="blah" >
<FirstName>Jimbob</FirstName>
<LastName>McGoo</LastName>
</ab:MyControl>
Where firstname and lastname are properties of type string, of the MyControl
Class.
I have the simple class inherited from control, i.e
[ParseChildrenAttribute(true)]
public class MyControl : Control
{
private string m_firstName = string.Empty;
private string m_lastName = string.Empty;
public string FirstName
{
get { return m_firstName ; }
set { m_firstName = value;}
}
public string LastName
{
get { return m_lastName ; }
set { m_lastName = value;}
}
public void Control_Load(object sender, EventArgs e)
{
Response.Write( m_firstName + " " + m_lastName);
}
public MyPlaceHolder() : base()
{
this.Load += new EventHandler(Control_Load);
}
When I try to run the code, i get the error "Literal content ('Jimbob') is
not allowed within a 'System.String'."
Cheers
Aaron