Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DoPostBack mthod call not inserted into html when override Render

Reply
Thread Tools

DoPostBack mthod call not inserted into html when override Render

 
 
Zuel
Guest
Posts: n/a
 
      01-07-2005
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.Ind exOf(">")+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").GetEnu merator();
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

 
Reply With Quote
 
 
 
 
Karl Seguin
Guest
Posts: n/a
 
      01-07-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> 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.Ind exOf(">")+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").GetEnu merator();
> 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
>



 
Reply With Quote
 
 
 
 
Zuel
Guest
Posts: n/a
 
      01-07-2005
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

 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      01-07-2005
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
| 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.Ind exOf(">")+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").GetEnu merator();
| 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
|


 
Reply With Quote
 
Zuel
Guest
Posts: n/a
 
      01-07-2005
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) oups.com...
> | 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.Ind exOf(">")+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").GetEnu merator();
> | 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
> |


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DoPostBack sometimes isn't in HTML Kevin ASP .Net 8 05-22-2013 07:15 AM
DoPostBack mthod call not inserted into html when override Render Zuel ASP .Net Web Controls 4 01-07-2005 08:00 PM
Override Render method in Label Control Jason Dean ASP .Net 3 12-22-2004 01:12 AM
Page.Render do not render complete page Lau Lei Cheong ASP .Net 1 05-15-2004 04:10 AM
how to override RadioButtonList render? DesignerX ASP .Net 1 12-19-2003 09:20 PM



Advertisments