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!)
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?
First thing I do is put this in the web.config btw: <system.webServer> <validation validateIntegratedModeConfiguration="false" /> <modules runAllManagedModulesForAllRequests="true">
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..
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?
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. ;-)
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!)
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?
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">
Yes, I am using .NET 3.5 web.config with both of these settings.
How are you hooking up the event, are you setting it in the ASCX file or in code?
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.
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
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. ;-)
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?
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.
is working on a reply...