e.cancel always restores DetailsView fields?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
10/20/2009 6:42:05 PM
Gravatar
Total Posts 112

e.cancel always restores DetailsView fields?

Hi All;

When using "mojoPortal Version 2.2.2.8 MSSQL" in a simple Module I verify the data quality in DetailsView1_ItemUpdating(). If there are data problems I send the user a message and e.cancel. Sadly all the DetailsView fields are restored to their pre-user-entry content when they might only have to change one small problem they have to re-enter all their data.

Is it possible to validate the data and reject it without throwing all the data entry away?

I look forward to hearing from you,
Dale E. Moore

 

10/21/2009 6:33:49 AM
Gravatar
Total Posts 18439

Re: e.cancel always restores DetailsView fields?

possibly that is the behavior by design to restore old values when updating is cancelled or perhaps your code is rebinding it after this in another event.

This is one of those "let me google that for you" questions. ;-)

Best,

Joe

10/21/2009 9:40:15 PM
Gravatar
Total Posts 112

Re: e.cancel always restores DetailsView fields?

Dear Joe;

I try to avoid bothering you until I've done some research. Sadly my Googling and head scratching came to naught. But as always, your words spurred me to a new and interesting quest.

I wrote an asp.net WebApplication outside MojoPortal and found it kept the NewValues on e.cancel = true. Then I substituted this functional code into a MojoPortal simple Module and it fails, keeping the OldValues instead.

I really hate for this one page to stand outside MojoPortal; do you have any further hints to set me questing?
Dale

10/21/2009 11:09:59 PM
Gravatar
Total Posts 112

Re: e.cancel always restores DetailsView fields?

Dear Joe;

Perhaps I chose poorly in using the GridView and DetailsView controls. Would you have another suggestion for me to implement similar functionality and still be within MojoPortal simple Module guidelines?

As always, thanks;
Dale

10/22/2009 11:54:31 AM
Gravatar
Total Posts 18439

Re: e.cancel always restores DetailsView fields?

Only thing I might suggest is make sure you have Page.EnableViewstate = true; in page load.

Not having any idea what your code is doing I have no way to diagnose it.

I suggest set some break points and step through the code and see at what point it loses the new values.

I don't find myself using DetailsView often but see no problem with using it and sure I could get it working if I needed it.

If you're using Mono it could be a Mono bug as well.

Best,

Joe

10/22/2009 2:31:37 PM
Gravatar
Total Posts 112

Re: e.cancel always restores DetailsView fields?

Hi Joe;

I created a WebApplication and on the Default page put GridView and DetailsView and they kept the OldValues when e.cancel = true.

Then I cut up Default and put it into my MojoPortal simple Module and found that it does not keep the OldValues.

Then I cut up my MojoPortal simple Module and had it Response.Redirect to (a renamed) Default and it works fine, but it looks a little hinky (is that really a word?)

I might just stay here,
Dale

PS: I appreciate this conversation with you!

10/22/2009 2:35:53 PM
Gravatar
Total Posts 18439

Re: e.cancel always restores DetailsView fields?

Please try encapsulating it in a UserControl and try that in a non mojoportal page so that you are comparing apples to apples.

It could be a difference between using it in a UserControl vs a Page rather than a mojoPortal issue other than that a mojoPortal module is going to be a UserControl.

For example be careful of using ajax page methods, they only work in a page not in a UserControl unless the page that the usercontrol is on has the method.

Hope it helps,

Joe

10/22/2009 6:07:42 PM
Gravatar
Total Posts 112

Re: e.cancel always restores DetailsView fields?

The UserControl retains NewValues.

Thanks for the suggestion to try UserControl - you are expanding my mind:)

Give me another one; boss!

10/23/2009 2:45:34 PM
Gravatar
Total Posts 18439

Re: e.cancel always restores DetailsView fields?

Possibly its a difference between a UserControl declared on a page or a UserControl added dynamically during the page load event of the page, try adding your UserControl to the page with code like

Control c = Page.LoadControl("~/pathtoyour.ascx";

pnlFoo.Controls.Add(c);

<asp:Panel id="pnlFoo" runat="server" would live on the page and you would load the control during page load.

Do some searching on the issues with events for dynamcially loaded controls in ASP.NET.

Hope it helps,

Joe

10/23/2009 4:40:59 PM
Gravatar
Total Posts 112

Re: e.cancel always restores DetailsView fields?

The dynamically loaded UserControl retains NewValues.

Is the next step debugging after e.cancel to figure out what restores the OldValues? That seems an exhausting exercise. I've done a bit of that some time back and gotten lost. Any hints from the master? Or other guidance?

10/24/2009 8:31:04 AM
Gravatar
Total Posts 18439

Re: e.cancel always restores DetailsView fields?

Hi Dale,

being able to step through the code with the debugger is something you should get comfortable with so I would look at this as an opportunity. Visual studio makes it very easy. Set break points in your page load, page init and other events, open Web.config file in VS (this is just to make sure it starts at the home page and doesn't try to launch your custom code first) then press the play button to launch the debugger. When the site comes up navigate to the page where your custom feature is and it should stop execution at the first breakpoint it encounters, then you can step through the code using the F11 key and inspect variables as the code executes to see where and when their values are changing.

Hope it helps,

Joe

You must sign in to post in the forums. This thread is closed to new posts.