Hi RickGot this working now to generate text input boxes dependant on user
Used this approach that you suggested :
Another alternative for dynamically generated content is to just generate plain HTML and embed it into a wwWebLiteral control. The literal control renders any text as is and so content comes out as is. You can even use some of the HtmlHelpers (in wwHtmlHelpers.prg) to facilitate that process to handle things like Auto-Postbacks and model assignment.
Using the htmlhelpers like this
lcHtml = HtmlTextBox("txtCompany",oudocket.oData.Company)
and then pasting into page object using a wwWebLiteral control. Everything renders correctly and the Automatic Postback works a treat.The issue I am having is getting the data to unbind I am using the business object rather than tables.
I reload my data using
x=oudocket.LOAD(this.passeddataId)
this.UnbindData()
IF this.BindingErrors.Count > 0
this.ErrorDisplay.Text = this.BindingErrors.ToHtml()
RETURN
ELSE
this.ErrorDisplay.ShowError("data saved ok " )
RETURN
ENDIF
Don't get a binding error I tyhink the issue is that as I have injected the HTML at load time the necessary logic for unbind won't have been introduced by the parser (although not at all sure)
Do I need to code the unbind for each element i have injected into the page during load ?
Thanks again for your help
Regards
Mark
Thanks Rick
I guessed I was the wrong side of the Parser.
Using a page frame and injecting elements gives me exactly what i need.
In my old classic version i had multiple templates which were called dependant upon user security levels.
This approach lets me control restricted content and add in when valid - means just one page Albeit a little more complicated.
Thanks Again
Mark
Hi Mark,
I'm not quite sure what you're trying to do...
I'm guessing you want to create content to embed into the page, right? In that case you can't generate the HTML Markup for controls, because that markup is parsed at COMPILE time (ie. before any code in the page runs). So you can't add <ww:wwWebTextBox /> as text into the page and expect that to render because the parsing is already done when the page runs.
However, you *can* add new controls like a new TextBox or label or datagrid to an existing Page or Container and add it to the page:
loTextBox = CREATEOBJECT("wwWebTextBox")
loTextBox.Id = "txtName"
loTextBox.Value = "Dynamically added text"
THIS.panDynamicPanel.AddControl(loTextBox)
Generally if you inject visible controls you'll want to add them to some other container control that effectively makes up the area where you need to embed the dynamic controls. Otherwise you don't have any control where the controls go as they are always added to the bottom of the ChildControls collection.
Another alternative for dynamically generated content is to just generate plain HTML and embed it into a wwWebLiteral control. The literal control renders any text as is and so content comes out as is. You can even use some of the HtmlHelpers (in wwHtmlHelpers.prg) to facilitate that process to handle things like Auto-Postbacks and model assignment.
But all that said - for meta Web pages that dynamically create content based on data structures from the database, Web Control Pages are not the best choice since they expect a rigid structure of a page to begin with. It's possible to do, but makes sense only if you build the entire page dynamically. If you want an idea of what that looks like, look at the source for a generated page - basically your code can use this same logic to dynamically create a page layout at runtime (or inject into a base page as long as you have a container that you can AddControl() to.
+++ Rick ---
Hi All
I am currently bringing my old classic app up to date and i am starting to confuse myself.
I am trying to build flexibilty into the form content.
I have built a base page with Headers & footers using ASCX
Added a little fixed HTML.
What I am trying to do is only show data that the user is authorised to edit.
I have added a chunk of code in the on load to generate the additional elements how do I get them to render? I am just getting the text but no input boxes which makes sense as the fields haven't been processed by the handler.
Copy of HTML from View Source
table class="" >
<tr>
<td class="recordheaderlight">Dict(f) : Docket:</td>
<td><ww:wwWebTextBox runat="server" id="txtDocket" ControlSource="oudocket.odata.Docket" /></td>
</tr>
<tr>
<td class="recordheaderlight">Dict(f) : Descrip:</td>
<td><ww:wwWebTextBox runat="server" id="txtDescrip" ControlSource="oudocket.odata.Descrip" /></td>
</tr>
<tr>
<td class="recordheaderlight">Dict(f) : Ordqty:</td>
<td><ww:wwWebTextBox runat="server" id="txtOrdqty" CssClass="number" ControlSource="oudocket.odata.Ordqty" style="text-align: right" /></td>
</tr>
</table></center>
<
I think my best approach is probably to process in the classic way generating the HTML on the fly using the new helpers and return that back to browser rather than trying to make the framework do this.
Framework is graet for normal approach I am trying to achieve the impossible ?
Just wondered if anyone had come up with a way of altering framework pages on the fly. Has been a long day and I may have missed something.
Thanks
Mark