Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Greg 9 posts 30 karma points
    May 23, 2010 @ 15:24
    Greg
    0

    update of data via usercontrol fails

    Hi,

    umbraco 4.0.3

    asp.net 3.5

    This is a bit of a hairy one.

    I have developed a usercontrol which is meant to update some data in database when the user clicks the 'Update' button. The data is entered into text boxes on a databound ascx control. It works fine when the control is placed on an aspx page in a non-umbraco web app. However, when the ascx page gets rendered in the usual way within umbraco via a macro, it databinds correctly but no updates are sent to the DB. The DataSourceView.ExecuteUpdate() method never gets called basically.

    Has anyone come across this problem before? Does umbraco do anything before it passes the update event down to the ascx control?

    umbraco and my test app both live on the same server and talk to the same DB. The only difference is the ascx being rendered within umbraco.

    The obvious way around this would be for me to develop a seperate web app which would run outside of umbraco. However I think it's better to render the ascx within umbraco. It means that I wouldn't have to change the look and feel in 2 places should the look and feel ever change.

    BTW I am using nettiers as the DB layer.

    Thank you for your help. I realise this is a difficult problem to diagnose (well hopefully I am wrong and it's easy!)

  • Greg 9 posts 30 karma points
    May 23, 2010 @ 15:48
    Greg
    0

    Some further info...

    I have placed a button on the ASCX page, I created a click event for it and when I click it, the postback occurs but the click event doesn't get fired. Hmmmm...I think this might be the problem but why?

  • Stefan Kip 1614 posts 4131 karma points c-trib
    May 23, 2010 @ 16:47
    Stefan Kip
    0

    Are you using Umbraco's .NET 3.5 web.config?

    First thing I do is put this in the web.config btw:
    <system.webServer>
        <validation validateIntegratedModeConfiguration="false" />
            <modules runAllManagedModulesForAllRequests="true">

     

  • Greg 9 posts 30 karma points
    May 23, 2010 @ 23:17
    Greg
    0

    Yes, I am using .NET 3.5 web.config with both of these settings.

  • Aaron Powell 1708 posts 3046 karma points c-trib
    May 24, 2010 @ 00:47
    Aaron Powell
    0

    How are you hooking up the event, are you setting it in the ASCX file or in code?

  • Greg 9 posts 30 karma points
    May 24, 2010 @ 01:34
    Greg
    0

    I am hooking it up in code so I placed the ASCX file in the /usercontrols directory and copied the DLL to the umbraco /bin folder.

  • Richard Soeteman 4046 posts 12899 karma points MVP 2x
    May 24, 2010 @ 07:41
    Richard Soeteman
    0

    Hi Greg,

    In which event are you hooking up the events? If in anything other than Page_Init, move the  hooking up of events to the page_init event. This is the page event where asp.net  wants you to initialize controls hook up Event Hanlders etc. And since Umbraco is a native ASP.Net application Umbraco wants it also..

    Cheers,

    Richard

  • Greg 9 posts 30 karma points
    May 24, 2010 @ 08:04
    Greg
    0

    Ok,

    I have added this to my ASCX control.

    protected void Page_Init(object sender, EventArgs e)
    {
            this.Button1.Click += new EventHandler(Button1_Click);
    }

    I put a breakpoint on it and it is hit before the Page_Load event. However when I click Button1 the Button1_Click event does not get fired.

    I hope this is something very simple. ;-)

  • Greg 9 posts 30 karma points
    May 24, 2010 @ 08:13
    Greg
    0

    Ok, I have found something interesting. The value of Page.IsPostBack = False in the Page_Load event of the ASCX after I click the button. I would have thought it should be True, yes?

  • Greg 9 posts 30 karma points
    May 24, 2010 @ 13:04
    Greg
    1

    I solved it. LinkButton control on the ASCX page was causing the data not to update.

    Basically the same issue as in this post.. http://our.umbraco.org/forum/using/ui-questions/8671-Using-AutoComplete-Ajax-Toolkit-Control-under-Umbraco?p=1

    Grrrrrrrr...I love umbraco and I am doing all sorts of crazy stuff with it but this little quirk really took a lot of my effort to solve which didn't make me love as much. ;-)

    Anyway, thank you all for your help.

Please Sign in or register to post replies

Write your reply to:

Draft