How to build a dynamic page

V

vodafone

Hy all

I've a little problem. I need to write a dynamic page that render
control according to validation status return from previous control
validation status.

To be clear, I've page that starts requesting some info, then user
press a button, and the same page should show the new field only if
validation returns true. But it sounds not so simple to do.

According to line-guide this is what happens in the order

Page_load - load the control
Validation_Handler - check for validity of content
Page_prerender - last chance to modify content

Validation_handler could be skipped if the submitting button (those
with causevalidation, has the property setted to false, but this mean
that I should perform the check manually).

In a first moment I think, move the control creation on the
page_prerender, but I see that there the addhandler routine, despite
valid for compilator, is still unusefull because it's ignored by the
server, so the dynamic button (at least those need to perform the
causevalidation) should always create on the load. This wasn't a
problem.
But in a second moment, when passing for the validation_handler I saw
that creating control on the render event, because control wasn't
created yet the page.isvalid after a page.validate still return always
true.

Then started my problem. I really don't know how to display dynamic
control according to page's validate status.

Any help? Unfortunately I'm so focused on my idea now, that I'm not
able to see the right solution. It's more then 4 hours that I get round
problem, but I'm so blind to don't show the way to solve it. And I
don't wanna to think it's impossible. It was possible - with some
escamotage - with old ASP ...

Thanks
Andrea
 
G

Guest

Hello,
I would try to make the item invisible, and if page.IsValid is true, make
the "hidden" item visible.

It would be something like this:
---- on page.aspx
....
<asp:textbox id="validatedTextBox" runat="server" />
<asp:requiredfieldvalidator runat="server"
controltovalidate="validatedTextBox" />
<asp:button runat=server id="myButton">

<asp:textbox id="toBeShownLater" runat="server" visible="false" />
....
'---- on page.aspx.vb
....
private sub myButton_click(sender as Object, e as EventArgs) Handles
myButton.Click
if page.IsValid then
toBeShownLater.visible = true
End if
End sub
....

If you are to show many elements, you can enter them within an <asp:table>
and make the table invisible.

Should you have any question or comments, let me know.

Regards,
Cesar
 
A

Andrea Moro

I would try to make the item invisible, and if page.IsValid is true, make
the "hidden" item visible.

This mean that all page should be built in one step. It doesn't sound very
nice. Better, because according to first user selection, fiels changes
completely from solution to solution (there are up to 64 possibility) and
for 10 of them there will be the chance that steps to finish grow up to 11
steps instead the normal two, the hiding solution won't be the easiest one.

Just to know. How do you normally use the validation? Just with a single
page step? Could you try to post a stupid sample of two nested page like I
need? or some usefull links.
I don't believe that it's impossible. I suppose then that could be more
convenient to buy the Plumb Components. It should avoid this kind of
problems. But as stupid as I can be, I don't wanna to think that MS
implemented this time-reduction solution for validation and inserted those
limit (that will overcome with 2.0) that annoy ASP.net programmer.

Sincerely
Andrea Moro
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,242
Latest member
KendrickKo

Latest Threads

Top