Help!. I need help with a form on a site I am building in C#.NET. The structure of the site is done. It is complex system that goes through the following steps..
1. Reads a template file (the pages main HTML code)
2. Parses the code, outputting most of it to a HtmlTextWriter object and looking for special tokens that I put in. A typical 'token' is the the one called 'sidenav'. (this one writes out the side navigation on the page)
3. Once a token is found, the matching user control is loaded, with this code...
Controls.AddAt(0, LoadControl(strUserControl));
Controls[0].RenderControl(writer);
base.Controls.Remove(base.Controls[0]);
This code is called from an override of the Render and OnPreRender classes, in the file called BasePage, (that is inherited by every page on the site).
One of the usercontrols that gets loaded is called 'survey'. This user control, will load one of 4 user controls that each have a form in them (parts 1-4 of a survey).
The 'survey' user control uses this code to load the approprate user control.....
Control control = LoadControl (Session["SurveyForm"].ToString() + ".ascx"
;
lblSurveyForm.Controls.Add (control);
Where Session["SurveyForm"] might equal 'survey1', the first time in.
In the user control survey1.ascx, there is a form. This, is the only form on the site at this point in time. (good, as .net cannot do more than one form that has runat='server' set.).
The problem is this. I can hit the 'next>' button on the form which submits it, the page reloads, as if it submitted, but no values are submitted. Not only that, but Page.IsPostBack equals false, no matter how many times I submit the form. Therefore I am not given a chance to request the values out of the form.
There must be solution to this. I cannot believe that .NET cannot process a form that is loaded from a dynamically loaded user control.
Could the problem be that i am not using a HTMLTextWritter object in the second instance? (If it is, now do I do that? I only seem to be able to get it working in the Render method)
Any help with this would be greatly appriciated.
Thanks in advance.
1. Reads a template file (the pages main HTML code)
2. Parses the code, outputting most of it to a HtmlTextWriter object and looking for special tokens that I put in. A typical 'token' is the the one called 'sidenav'. (this one writes out the side navigation on the page)
3. Once a token is found, the matching user control is loaded, with this code...
Controls.AddAt(0, LoadControl(strUserControl));
Controls[0].RenderControl(writer);
base.Controls.Remove(base.Controls[0]);
This code is called from an override of the Render and OnPreRender classes, in the file called BasePage, (that is inherited by every page on the site).
One of the usercontrols that gets loaded is called 'survey'. This user control, will load one of 4 user controls that each have a form in them (parts 1-4 of a survey).
The 'survey' user control uses this code to load the approprate user control.....
Control control = LoadControl (Session["SurveyForm"].ToString() + ".ascx"

lblSurveyForm.Controls.Add (control);
Where Session["SurveyForm"] might equal 'survey1', the first time in.
In the user control survey1.ascx, there is a form. This, is the only form on the site at this point in time. (good, as .net cannot do more than one form that has runat='server' set.).
The problem is this. I can hit the 'next>' button on the form which submits it, the page reloads, as if it submitted, but no values are submitted. Not only that, but Page.IsPostBack equals false, no matter how many times I submit the form. Therefore I am not given a chance to request the values out of the form.
There must be solution to this. I cannot believe that .NET cannot process a form that is loaded from a dynamically loaded user control.
Could the problem be that i am not using a HTMLTextWritter object in the second instance? (If it is, now do I do that? I only seem to be able to get it working in the Render method)
Any help with this would be greatly appriciated.
Thanks in advance.