DoPostBack mthod call not inserted into html when override Render

Discussion in 'ASP .Net Web Controls' started by Zuel, Jan 7, 2005.

  1. Zuel

    Zuel Guest

    Hi Folks.
    So I have a small problem. My DoPostBack function is not writen to
    the HTML page nor are the asp:buttons calling the DoPostBack.

    My Goal is to create a totaly dynamic web page where the server
    generates the HTML based on a passed in parameter. In our case,
    CustomerID. Every Customer ges a branded website with there logos and
    webpage etc.. To Avoid having 1 ASP.Net application running for each
    client I am attempting a more dynamic rout.

    To do this I need to be able to get the Branding stuff and inject it
    into the webpage.

    This is accomplished with various controls.

    the .aspx is suposed to generate the clients branded web page. This
    usually contains some logos and borders. So it's basically a table
    with background images.

    Then in this table I have a .ascx user control. It's job is to
    dynamically insert the client selected controls. The client is able to
    choose the layout and what controls to place on the page. So this
    ..ascx html is retrieved from the database keeping in mind it's simply a
    table where each cell references prefabed controls.

    The prefabed controls are created and generate like any other control
    and nothing further should be necessary to insert them into the branded
    webpage.

    So the important stuff from the default.aspx looks like this:

    <%@ Register TagPrefix="branding" TagName="MainPage"
    Src="MainPage.ascx" %>
    <%@ Page language="c#" Codebehind="default.aspx.cs"
    AutoEventWireup="false" Inherits="SandBox._default" %>

    <form id="branding" method="post" runat="server">
    <branding:MainPage id="ETranWebPage"
    runat="server"></etran:MainPage>
    </form>


    The Mainpage control is the .ascx from above and it's html content is
    retrieved from a database call based on Client and looks something like
    this.


    <Table>
    <TR><TD>formatted HTML</TD></TR>
    <TR><TD>
    <control1 runat="server">
    <Properties>
    <Property
    name="buttonText">login</Property>
    </Properties>
    </control1>
    </TD></TR>
    <TR><TD>Some extra stuff</TD></TR>
    </table>

    The MainPage control overrides Render. In Render it parses the XHTML
    above and dynamically inserts the correct control.

    This information is also retrieved from an XML file and stored in a
    hashtable. Key=id. Notice the id value matches the above xhtml's
    element.

    <Control source="testControl1.ascx" id="control1"
    className="SandBox.testControl1"/>

    Since I cannot simplifiy this too much.. Here is the code behind the
    render.

    private void Render(XmlNode node, HtmlTextWriter output) {
    IEnumerator iEnum;
    IEnumerator nl =
    ((XmlNode)node).ChildNodes.GetEnumerator();
    if(nl.MoveNext()==false) {
    output.Write(node.Value);
    }else{
    do {
    XmlNode n = (XmlNode)nl.Current;
    if(n.GetType() == typeof(XmlElement)) {
    XmlElement e = (XmlElement)n;
    if(mPageControls.ContainsKey(e.Name)) {
    this.RenderETranControl(e,output);
    }else {


    if(n.ChildNodes.GetEnumerator().MoveNext()==false) {
    output.Write(node.Value);
    }else{

    output.Write(n.OuterXml.Substring(0,n.OuterXml.IndexOf(">")+1));
    this.Render(n,output);
    output.Write("</");
    output.Write(n.Name);
    output.Write(">");
    }
    }
    }else {
    this.Render(n,output);
    }
    }while(nl.MoveNext());
    }
    }

    public void RenderETranControl(XmlElement e, HtmlTextWriter
    output) {
    IEnumerator iEnum;

    ETranWebControl control =
    (ETranWebControl)mPageControls[e.Name];
    Control c = (Control)LoadControl(control.source);
    c.ID = control.id;
    XmlAttributeCollection attributes = e.Attributes;
    iEnum = attributes.GetEnumerator();
    while(iEnum.MoveNext()) {
    XmlAttribute attribute = (XmlAttribute)iEnum.Current;
    }
    iEnum =
    e.GetElementsByTagName("Properties").GetEnumerator();
    if(iEnum.MoveNext()) {
    XmlElement properties = (XmlElement)iEnum.Current;
    iEnum =
    properties.GetElementsByTagName("Property").GetEnumerator();
    while(iEnum.MoveNext()) {
    XmlElement property = (XmlElement)iEnum.Current;
    string propertyName =
    property.GetAttribute("name");
    string value = property.InnerText;
    Type controlType = c.GetType();
    try{
    PropertyInfo pInfo =
    controlType.GetProperty(propertyName);
    pInfo.SetValue(c,value,null);
    }catch(Exception ex) {
    // Add Logging
    }
    }
    }
    // Controls.Add(c);
    c.RenderControl(output);

    }

    Here is the control's html


    <%@ Control Language="c#" AutoEventWireup="false"
    Codebehind="testControl1.ascx.cs" Inherits="SandBox.testControl1"
    TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>

    <asp:Button id="Button1" Text="Button" runat="server"></asp:Button>

    and here we have the html output.

    <script language="javascript" type="text/javascript">

    </HEAD>
    <body>
    <form name="ETran" method="post" action="default.aspx"
    id="ETran">
    <input type="hidden" name="__VIEWSTATE"
    value="dDwxMDQxNzA2MzQ5Ozs+K/wXsV22klaSnVgoGGt1YT6Hl94=" />

    <Table><TR><TD>formatted HTML</TD></TR><TR><TD><input
    type="submit" name="control1:Button1" value="login"
    id="control1_Button1" />
    </TD></TR><TR><TD>Some extra stuff</TD></TR></Table>
    </form>
    </body>
    </HTML>

    There is no doPostBack anything in the html output.
    If you could help out I would greatly appreciate it!

    Erik
     
    Zuel, Jan 7, 2005
    #1
    1. Advertising

  2. Zuel

    Karl Seguin Guest

    I think you are going about this the wrong way. If you have some time,
    check out the Community server Starter Kit
    (http://www.asp.net/Default.aspx?tabindex=8&tabid=47) and see how they go
    about dynamically positioning controls.

    I can give you a brief overview. In the database they'll have the list of
    controls a user wants displayed and where that control is to be displayed,
    say something like:

    Control Parent
    Weather.ascx LeftSide
    Calendar.ascx LeftSide
    Biography MainContent


    then in code, they'll get the information and dynamically look for the
    parent:

    foreach (DataRow dr in someDataTableThatGotTheAbove.Rows){
    Control container = Page.FindControl(Convert.ToString(dr("Parent")));
    //can cache this looking in a hashtable
    if (container != null){
    Control c = Page.LaodControl(Convert.ToString(dr("Control")));
    //error checking here would be nice
    container.Controls.Add(c);
    }
    }

    As you can see, the solution is considerably simpler. When you start making
    use of common baseclasses or interfaces things become even smoother.

    Karl
    --
    MY ASP.Net tutorials
    http://www.openmymind.net/


    "Zuel" <> wrote in message
    news:...
    > Hi Folks.
    > So I have a small problem. My DoPostBack function is not writen to
    > the HTML page nor are the asp:buttons calling the DoPostBack.
    >
    > My Goal is to create a totaly dynamic web page where the server
    > generates the HTML based on a passed in parameter. In our case,
    > CustomerID. Every Customer ges a branded website with there logos and
    > webpage etc.. To Avoid having 1 ASP.Net application running for each
    > client I am attempting a more dynamic rout.
    >
    > To do this I need to be able to get the Branding stuff and inject it
    > into the webpage.
    >
    > This is accomplished with various controls.
    >
    > the .aspx is suposed to generate the clients branded web page. This
    > usually contains some logos and borders. So it's basically a table
    > with background images.
    >
    > Then in this table I have a .ascx user control. It's job is to
    > dynamically insert the client selected controls. The client is able to
    > choose the layout and what controls to place on the page. So this
    > .ascx html is retrieved from the database keeping in mind it's simply a
    > table where each cell references prefabed controls.
    >
    > The prefabed controls are created and generate like any other control
    > and nothing further should be necessary to insert them into the branded
    > webpage.
    >
    > So the important stuff from the default.aspx looks like this:
    >
    > <%@ Register TagPrefix="branding" TagName="MainPage"
    > Src="MainPage.ascx" %>
    > <%@ Page language="c#" Codebehind="default.aspx.cs"
    > AutoEventWireup="false" Inherits="SandBox._default" %>
    >
    > <form id="branding" method="post" runat="server">
    > <branding:MainPage id="ETranWebPage"
    > runat="server"></etran:MainPage>
    > </form>
    >
    >
    > The Mainpage control is the .ascx from above and it's html content is
    > retrieved from a database call based on Client and looks something like
    > this.
    >
    >
    > <Table>
    > <TR><TD>formatted HTML</TD></TR>
    > <TR><TD>
    > <control1 runat="server">
    > <Properties>
    > <Property
    > name="buttonText">login</Property>
    > </Properties>
    > </control1>
    > </TD></TR>
    > <TR><TD>Some extra stuff</TD></TR>
    > </table>
    >
    > The MainPage control overrides Render. In Render it parses the XHTML
    > above and dynamically inserts the correct control.
    >
    > This information is also retrieved from an XML file and stored in a
    > hashtable. Key=id. Notice the id value matches the above xhtml's
    > element.
    >
    > <Control source="testControl1.ascx" id="control1"
    > className="SandBox.testControl1"/>
    >
    > Since I cannot simplifiy this too much.. Here is the code behind the
    > render.
    >
    > private void Render(XmlNode node, HtmlTextWriter output) {
    > IEnumerator iEnum;
    > IEnumerator nl =
    > ((XmlNode)node).ChildNodes.GetEnumerator();
    > if(nl.MoveNext()==false) {
    > output.Write(node.Value);
    > }else{
    > do {
    > XmlNode n = (XmlNode)nl.Current;
    > if(n.GetType() == typeof(XmlElement)) {
    > XmlElement e = (XmlElement)n;
    > if(mPageControls.ContainsKey(e.Name)) {
    > this.RenderETranControl(e,output);
    > }else {
    >
    >
    > if(n.ChildNodes.GetEnumerator().MoveNext()==false) {
    > output.Write(node.Value);
    > }else{
    >
    > output.Write(n.OuterXml.Substring(0,n.OuterXml.IndexOf(">")+1));
    > this.Render(n,output);
    > output.Write("</");
    > output.Write(n.Name);
    > output.Write(">");
    > }
    > }
    > }else {
    > this.Render(n,output);
    > }
    > }while(nl.MoveNext());
    > }
    > }
    >
    > public void RenderETranControl(XmlElement e, HtmlTextWriter
    > output) {
    > IEnumerator iEnum;
    >
    > ETranWebControl control =
    > (ETranWebControl)mPageControls[e.Name];
    > Control c = (Control)LoadControl(control.source);
    > c.ID = control.id;
    > XmlAttributeCollection attributes = e.Attributes;
    > iEnum = attributes.GetEnumerator();
    > while(iEnum.MoveNext()) {
    > XmlAttribute attribute = (XmlAttribute)iEnum.Current;
    > }
    > iEnum =
    > e.GetElementsByTagName("Properties").GetEnumerator();
    > if(iEnum.MoveNext()) {
    > XmlElement properties = (XmlElement)iEnum.Current;
    > iEnum =
    > properties.GetElementsByTagName("Property").GetEnumerator();
    > while(iEnum.MoveNext()) {
    > XmlElement property = (XmlElement)iEnum.Current;
    > string propertyName =
    > property.GetAttribute("name");
    > string value = property.InnerText;
    > Type controlType = c.GetType();
    > try{
    > PropertyInfo pInfo =
    > controlType.GetProperty(propertyName);
    > pInfo.SetValue(c,value,null);
    > }catch(Exception ex) {
    > // Add Logging
    > }
    > }
    > }
    > // Controls.Add(c);
    > c.RenderControl(output);
    >
    > }
    >
    > Here is the control's html
    >
    >
    > <%@ Control Language="c#" AutoEventWireup="false"
    > Codebehind="testControl1.ascx.cs" Inherits="SandBox.testControl1"
    > TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    >
    > <asp:Button id="Button1" Text="Button" runat="server"></asp:Button>
    >
    > and here we have the html output.
    >
    > <script language="javascript" type="text/javascript">
    >
    > </HEAD>
    > <body>
    > <form name="ETran" method="post" action="default.aspx"
    > id="ETran">
    > <input type="hidden" name="__VIEWSTATE"
    > value="dDwxMDQxNzA2MzQ5Ozs+K/wXsV22klaSnVgoGGt1YT6Hl94=" />
    >
    > <Table><TR><TD>formatted HTML</TD></TR><TR><TD><input
    > type="submit" name="control1:Button1" value="login"
    > id="control1_Button1" />
    > </TD></TR><TR><TD>Some extra stuff</TD></TR></Table>
    > </form>
    > </body>
    > </HTML>
    >
    > There is no doPostBack anything in the html output.
    > If you could help out I would greatly appreciate it!
    >
    > Erik
    >
     
    Karl Seguin, Jan 7, 2005
    #2
    1. Advertising

  3. Zuel

    Zuel Guest

    That is interesting. I see how it would be much simpler.. Using a
    data grid does simplify my MainPage logic. But this does not solve the
    fact that our site is branded to look like our clients site. Our
    company does bill payment. So when a person goes to say the electric
    company website to pay there monthly bill they are redirected to our
    servers for the bill payment process. We are selling this as a
    seamless integration to their website and the user is not even supposed
    to know he is no longer on his Electric company's website. A smart
    user would realize the URL change however but that's how we are selling
    the product.

    My first idea was an IFrame that would only hold the bill payment
    process and our clients could link us in that way. This would avoid us
    having to deal with client images and background branding. But as I am
    told, our clients don't know how to do this so it's not an option.
    Thus I am stuck with 100 unique webpage's with similar functionality.
    So for companyX we might have to check an account number before
    paying, or some may log in with an account number and a username..
    etc.. So we thought that we could capture 80% of our clients with
    re-usable user Controls and the other 20% with more customization VIA
    specifically customized controls or other.

    So as you can see the website can vary a lot even though the content is
    similar.

    We currently do this branding using 1 ASP.net application and a
    subdirectory for each client. All the pages inherit from common
    components so the functionality is encapsulated under the hood from
    these subdirectories. However, this presents a huge project to
    maintain.. Another alternative is to have an ASP.net application per
    client, but then our base code changes would not be reflected unless we
    updated every client. And source control would be a nightmare with a
    version per client.

    We have decided the best approach is to have multiple versions of the
    Application running on the ASP server. By version I mean code version
    and not client version. Then we are creating a traffic cop that will
    be able to direct what version a client is on based on a Database table
    lookup. And as the examples I originally posted is to make the
    projects more manageable..
    Thanks for your response and I am looking into the start kits.

    Erik
     
    Zuel, Jan 7, 2005
    #3
  4. Zuel

    bruce barker Guest

    asp:buttons do not use __doPostBack as they are rendered as submit buttons,
    so the browser will do the submit.

    note: if you want your site to work with javascript disabled, asp:buttons
    are the only postback control you should use.

    -- bruce (sqlwork.com)


    "Zuel" <> wrote in message
    news:...
    | Hi Folks.
    | So I have a small problem. My DoPostBack function is not writen to
    | the HTML page nor are the asp:buttons calling the DoPostBack.
    |
    | My Goal is to create a totaly dynamic web page where the server
    | generates the HTML based on a passed in parameter. In our case,
    | CustomerID. Every Customer ges a branded website with there logos and
    | webpage etc.. To Avoid having 1 ASP.Net application running for each
    | client I am attempting a more dynamic rout.
    |
    | To do this I need to be able to get the Branding stuff and inject it
    | into the webpage.
    |
    | This is accomplished with various controls.
    |
    | the .aspx is suposed to generate the clients branded web page. This
    | usually contains some logos and borders. So it's basically a table
    | with background images.
    |
    | Then in this table I have a .ascx user control. It's job is to
    | dynamically insert the client selected controls. The client is able to
    | choose the layout and what controls to place on the page. So this
    | .ascx html is retrieved from the database keeping in mind it's simply a
    | table where each cell references prefabed controls.
    |
    | The prefabed controls are created and generate like any other control
    | and nothing further should be necessary to insert them into the branded
    | webpage.
    |
    | So the important stuff from the default.aspx looks like this:
    |
    | <%@ Register TagPrefix="branding" TagName="MainPage"
    | Src="MainPage.ascx" %>
    | <%@ Page language="c#" Codebehind="default.aspx.cs"
    | AutoEventWireup="false" Inherits="SandBox._default" %>
    |
    | <form id="branding" method="post" runat="server">
    | <branding:MainPage id="ETranWebPage"
    | runat="server"></etran:MainPage>
    | </form>
    |
    |
    | The Mainpage control is the .ascx from above and it's html content is
    | retrieved from a database call based on Client and looks something like
    | this.
    |
    |
    | <Table>
    | <TR><TD>formatted HTML</TD></TR>
    | <TR><TD>
    | <control1 runat="server">
    | <Properties>
    | <Property
    | name="buttonText">login</Property>
    | </Properties>
    | </control1>
    | </TD></TR>
    | <TR><TD>Some extra stuff</TD></TR>
    | </table>
    |
    | The MainPage control overrides Render. In Render it parses the XHTML
    | above and dynamically inserts the correct control.
    |
    | This information is also retrieved from an XML file and stored in a
    | hashtable. Key=id. Notice the id value matches the above xhtml's
    | element.
    |
    | <Control source="testControl1.ascx" id="control1"
    | className="SandBox.testControl1"/>
    |
    | Since I cannot simplifiy this too much.. Here is the code behind the
    | render.
    |
    | private void Render(XmlNode node, HtmlTextWriter output) {
    | IEnumerator iEnum;
    | IEnumerator nl =
    | ((XmlNode)node).ChildNodes.GetEnumerator();
    | if(nl.MoveNext()==false) {
    | output.Write(node.Value);
    | }else{
    | do {
    | XmlNode n = (XmlNode)nl.Current;
    | if(n.GetType() == typeof(XmlElement)) {
    | XmlElement e = (XmlElement)n;
    | if(mPageControls.ContainsKey(e.Name)) {
    | this.RenderETranControl(e,output);
    | }else {
    |
    |
    | if(n.ChildNodes.GetEnumerator().MoveNext()==false) {
    | output.Write(node.Value);
    | }else{
    |
    | output.Write(n.OuterXml.Substring(0,n.OuterXml.IndexOf(">")+1));
    | this.Render(n,output);
    | output.Write("</");
    | output.Write(n.Name);
    | output.Write(">");
    | }
    | }
    | }else {
    | this.Render(n,output);
    | }
    | }while(nl.MoveNext());
    | }
    | }
    |
    | public void RenderETranControl(XmlElement e, HtmlTextWriter
    | output) {
    | IEnumerator iEnum;
    |
    | ETranWebControl control =
    | (ETranWebControl)mPageControls[e.Name];
    | Control c = (Control)LoadControl(control.source);
    | c.ID = control.id;
    | XmlAttributeCollection attributes = e.Attributes;
    | iEnum = attributes.GetEnumerator();
    | while(iEnum.MoveNext()) {
    | XmlAttribute attribute = (XmlAttribute)iEnum.Current;
    | }
    | iEnum =
    | e.GetElementsByTagName("Properties").GetEnumerator();
    | if(iEnum.MoveNext()) {
    | XmlElement properties = (XmlElement)iEnum.Current;
    | iEnum =
    | properties.GetElementsByTagName("Property").GetEnumerator();
    | while(iEnum.MoveNext()) {
    | XmlElement property = (XmlElement)iEnum.Current;
    | string propertyName =
    | property.GetAttribute("name");
    | string value = property.InnerText;
    | Type controlType = c.GetType();
    | try{
    | PropertyInfo pInfo =
    | controlType.GetProperty(propertyName);
    | pInfo.SetValue(c,value,null);
    | }catch(Exception ex) {
    | // Add Logging
    | }
    | }
    | }
    | // Controls.Add(c);
    | c.RenderControl(output);
    |
    | }
    |
    | Here is the control's html
    |
    |
    | <%@ Control Language="c#" AutoEventWireup="false"
    | Codebehind="testControl1.ascx.cs" Inherits="SandBox.testControl1"
    | TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    |
    | <asp:Button id="Button1" Text="Button" runat="server"></asp:Button>
    |
    | and here we have the html output.
    |
    | <script language="javascript" type="text/javascript">
    |
    | </HEAD>
    | <body>
    | <form name="ETran" method="post" action="default.aspx"
    | id="ETran">
    | <input type="hidden" name="__VIEWSTATE"
    | value="dDwxMDQxNzA2MzQ5Ozs+K/wXsV22klaSnVgoGGt1YT6Hl94=" />
    |
    | <Table><TR><TD>formatted HTML</TD></TR><TR><TD><input
    | type="submit" name="control1:Button1" value="login"
    | id="control1_Button1" />
    | </TD></TR><TR><TD>Some extra stuff</TD></TR></Table>
    | </form>
    | </body>
    | </HTML>
    |
    | There is no doPostBack anything in the html output.
    | If you could help out I would greatly appreciate it!
    |
    | Erik
    |
     
    bruce barker, Jan 7, 2005
    #4
  5. Zuel

    Zuel Guest

    Oh dear. Your correct. You see. My problem is that the events in the
    controls are not being called when I click a button. I thought this
    was due to the DoPostBack function.. :)

    Sometimes one makes an assumption. Ok.. I thought it was the fact
    that I was overriding the Render method that I was not getting the
    events properly. In fact it's probably a lil' deeper than that.

    Thanks..

    No if I can figure out why the event handler is not calling the proper
    event when the button is clicked I would be set!

    Erik




    bruce barker wrote:
    > asp:buttons do not use __doPostBack as they are rendered as submit

    buttons,
    > so the browser will do the submit.
    >
    > note: if you want your site to work with javascript disabled,

    asp:buttons
    > are the only postback control you should use.
    >
    > -- bruce (sqlwork.com)
    >
    >
    > "Zuel" <> wrote in message
    > news:...
    > | Hi Folks.
    > | So I have a small problem. My DoPostBack function is not writen to
    > | the HTML page nor are the asp:buttons calling the DoPostBack.
    > |
    > | My Goal is to create a totaly dynamic web page where the server
    > | generates the HTML based on a passed in parameter. In our case,
    > | CustomerID. Every Customer ges a branded website with there logos

    and
    > | webpage etc.. To Avoid having 1 ASP.Net application running for

    each
    > | client I am attempting a more dynamic rout.
    > |
    > | To do this I need to be able to get the Branding stuff and inject

    it
    > | into the webpage.
    > |
    > | This is accomplished with various controls.
    > |
    > | the .aspx is suposed to generate the clients branded web page.

    This
    > | usually contains some logos and borders. So it's basically a table
    > | with background images.
    > |
    > | Then in this table I have a .ascx user control. It's job is to
    > | dynamically insert the client selected controls. The client is

    able to
    > | choose the layout and what controls to place on the page. So this
    > | .ascx html is retrieved from the database keeping in mind it's

    simply a
    > | table where each cell references prefabed controls.
    > |
    > | The prefabed controls are created and generate like any other

    control
    > | and nothing further should be necessary to insert them into the

    branded
    > | webpage.
    > |
    > | So the important stuff from the default.aspx looks like this:
    > |
    > | <%@ Register TagPrefix="branding" TagName="MainPage"
    > | Src="MainPage.ascx" %>
    > | <%@ Page language="c#" Codebehind="default.aspx.cs"
    > | AutoEventWireup="false" Inherits="SandBox._default" %>
    > |
    > | <form id="branding" method="post" runat="server">
    > | <branding:MainPage id="ETranWebPage"
    > | runat="server"></etran:MainPage>
    > | </form>
    > |
    > |
    > | The Mainpage control is the .ascx from above and it's html content

    is
    > | retrieved from a database call based on Client and looks something

    like
    > | this.
    > |
    > |
    > | <Table>
    > | <TR><TD>formatted HTML</TD></TR>
    > | <TR><TD>
    > | <control1 runat="server">
    > | <Properties>
    > | <Property
    > | name="buttonText">login</Property>
    > | </Properties>
    > | </control1>
    > | </TD></TR>
    > | <TR><TD>Some extra stuff</TD></TR>
    > | </table>
    > |
    > | The MainPage control overrides Render. In Render it parses the

    XHTML
    > | above and dynamically inserts the correct control.
    > |
    > | This information is also retrieved from an XML file and stored in a
    > | hashtable. Key=id. Notice the id value matches the above xhtml's
    > | element.
    > |
    > | <Control source="testControl1.ascx" id="control1"
    > | className="SandBox.testControl1"/>
    > |
    > | Since I cannot simplifiy this too much.. Here is the code behind

    the
    > | render.
    > |
    > | private void Render(XmlNode node, HtmlTextWriter output) {
    > | IEnumerator iEnum;
    > | IEnumerator nl =
    > | ((XmlNode)node).ChildNodes.GetEnumerator();
    > | if(nl.MoveNext()==false) {
    > | output.Write(node.Value);
    > | }else{
    > | do {
    > | XmlNode n = (XmlNode)nl.Current;
    > | if(n.GetType() == typeof(XmlElement)) {
    > | XmlElement e = (XmlElement)n;
    > | if(mPageControls.ContainsKey(e.Name)) {
    > | this.RenderETranControl(e,output);
    > | }else {
    > |
    > |
    > | if(n.ChildNodes.GetEnumerator().MoveNext()==false) {
    > | output.Write(node.Value);
    > | }else{
    > |
    > | output.Write(n.OuterXml.Substring(0,n.OuterXml.IndexOf(">")+1));
    > | this.Render(n,output);
    > | output.Write("</");
    > | output.Write(n.Name);
    > | output.Write(">");
    > | }
    > | }
    > | }else {
    > | this.Render(n,output);
    > | }
    > | }while(nl.MoveNext());
    > | }
    > | }
    > |
    > | public void RenderETranControl(XmlElement e, HtmlTextWriter
    > | output) {
    > | IEnumerator iEnum;
    > |
    > | ETranWebControl control =
    > | (ETranWebControl)mPageControls[e.Name];
    > | Control c = (Control)LoadControl(control.source);
    > | c.ID = control.id;
    > | XmlAttributeCollection attributes = e.Attributes;
    > | iEnum = attributes.GetEnumerator();
    > | while(iEnum.MoveNext()) {
    > | XmlAttribute attribute = (XmlAttribute)iEnum.Current;
    > | }
    > | iEnum =
    > | e.GetElementsByTagName("Properties").GetEnumerator();
    > | if(iEnum.MoveNext()) {
    > | XmlElement properties = (XmlElement)iEnum.Current;
    > | iEnum =
    > | properties.GetElementsByTagName("Property").GetEnumerator();
    > | while(iEnum.MoveNext()) {
    > | XmlElement property = (XmlElement)iEnum.Current;
    > | string propertyName =
    > | property.GetAttribute("name");
    > | string value = property.InnerText;
    > | Type controlType = c.GetType();
    > | try{
    > | PropertyInfo pInfo =
    > | controlType.GetProperty(propertyName);
    > | pInfo.SetValue(c,value,null);
    > | }catch(Exception ex) {
    > | // Add Logging
    > | }
    > | }
    > | }
    > | // Controls.Add(c);
    > | c.RenderControl(output);
    > |
    > | }
    > |
    > | Here is the control's html
    > |
    > |
    > | <%@ Control Language="c#" AutoEventWireup="false"
    > | Codebehind="testControl1.ascx.cs" Inherits="SandBox.testControl1"
    > | TargetSchema="http://schemas.microsoft.com/intellisense/ie5"%>
    > |
    > | <asp:Button id="Button1" Text="Button" runat="server"></asp:Button>
    > |
    > | and here we have the html output.
    > |
    > | <script language="javascript" type="text/javascript">
    > |
    > | </HEAD>
    > | <body>
    > | <form name="ETran" method="post" action="default.aspx"
    > | id="ETran">
    > | <input type="hidden" name="__VIEWSTATE"
    > | value="dDwxMDQxNzA2MzQ5Ozs+K/wXsV22klaSnVgoGGt1YT6Hl94=" />
    > |
    > | <Table><TR><TD>formatted HTML</TD></TR><TR><TD><input
    > | type="submit" name="control1:Button1" value="login"
    > | id="control1_Button1" />
    > | </TD></TR><TR><TD>Some extra stuff</TD></TR></Table>
    > | </form>
    > | </body>
    > | </HTML>
    > |
    > | There is no doPostBack anything in the html output.
    > | If you could help out I would greatly appreciate it!
    > |
    > | Erik
    > |
     
    Zuel, Jan 7, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Timothy Kelley

    calling doPostBack not working

    Timothy Kelley, Jul 18, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    771
  2. Lau Lei Cheong

    Page.Render do not render complete page

    Lau Lei Cheong, May 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,118
    Lau Lei Cheong
    May 15, 2004
  3. Zuel
    Replies:
    4
    Views:
    2,186
  4. Mark Olbert
    Replies:
    9
    Views:
    19,101
    Chris Date
    Oct 30, 2009
  5. Kevin

    DoPostBack sometimes isn't in HTML

    Kevin, Feb 4, 2009, in forum: ASP .Net
    Replies:
    8
    Views:
    2,590
    kphani_prasad
    May 22, 2013
Loading...

Share This Page