This is a migrated thread and some comments may be shown as answers.

CommandName="Update" requires OnButtonClick

23 Answers 355 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Jon Stromer-Galley
Top achievements
Rank 1
Jon Stromer-Galley asked on 02 May 2008, 06:36 PM
Is it a bug that I have to include (at least) an empty event handler to have the default behavior for

CommandName="Update" and the other "built in detailsview commands"?

23 Answers, 1 is accepted

Sort by
0
Erjan Gavalji
Telerik team
answered on 05 May 2008, 12:15 PM
Hi Jon,

This behavior is by design - we made the RadToolBar control similar to the navigation controls (RadTreeView, RadMenu, etc). We are still considering if to change it to always perform a postback unless its PostBack property set to false, which might be the better decision for this type of control.

We'd really like to know your opinion on that, guys!

Thanks,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jon Stromer-Galley
Top achievements
Rank 1
answered on 07 May 2008, 03:13 PM
Hi Erjan,

Love the control set by the way.  Now that I know one needs an empty handler in the code behind, it is no big deal to include it.

When I saw that one could use CommandName="" in the toolbar I was expecting behavior more like an asp:button where one does not need a handler if one was using a "standard" CommandName like "Update" or "Insert".

Perhaps, adding the control to a form could automatically add the empty handler as well with a comment indicating why it was automatically added would keep the current functionality but I would not have been confused.

Best wishes
0
Erjan Gavalji
Telerik team
answered on 08 May 2008, 07:17 AM
Hi Jon,

Thanks again for the comments!

I'm not sure if the addition of an empty handler would not be confusing. We haven't taken the decision yet, but there are two most probable solutions:
  • Add an AutoPostBack property (defaulting to false, similar to RadToolBar "Classic");
  • Change RadToolBar to always perform a postback unless PostBack="false" set to a button item.
Cheers,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 13 May 2008, 02:43 PM
I migrated to the "Prometheus" version of the toolbar control.  Previously, with CommandName="Cancel", the toolbar would automatically close the usercontrol on which the toolbar was placed.  What do I need to do in the code behind for the user control in order to close it when the Cancel toolbar button is clicked?  I have created a RadToolBar2_ButtonClick event, but I assume that I need something equivalent to "parent.close()"?

Thanks
Jeff
0
Jon Stromer-Galley
Top achievements
Rank 1
answered on 13 May 2008, 02:50 PM
I used this:

protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
{
    // Telerik Bug? Need an empty handler
    //HandleToolBarClick((RadToolBarButton)e.Item);
}

If the only commands being sent are "cancle" or "update" or one of the other standard command then I left the HandleToolBarClick() commented out.  If there are commands that require custom logic I handled that in the HandleToolBarClick() but did not handle the standard commands.

0
Jeff Snyder
Top achievements
Rank 1
answered on 13 May 2008, 02:53 PM
Thanks Jon.  Yes, I have done the same thing as you with no luck.  I stepped into the event handler just to make sure that it is being fired...
0
Erjan Gavalji
Telerik team
answered on 13 May 2008, 02:55 PM
Hi Jeff Snyder,

There are a number of ways to "close" a user control. For example, you can set its Visible property to false, or you can remove it from the Controls collection of its parent. Here is a sample code for setting the control to invisible

protected void RadToolBar1_ButtonClick(object sender, EventArgs e)
{
    string commandName;
    if (e.Item is RadToolBarButton)
    {
       commandName = ((RadToolBarButton)e.Item).CommandName;
    }
    else
    {
       commandName = ((RadToolBarSplitButton)e.Item).CommandName;
    }
    if (commandName == "cancel")
    {
       myUserControl.Visible = false;
    }
}

I hope this helps.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 13 May 2008, 06:13 PM
Thanks Erjan.  I ended up doing a Parent.Visible = False in the codebehind for the user control.  Now, this same user control is the edit form for a RadGrid.  Previously, using the toolbar in the non-Prometheus version, the Update command for the toolbar inside the user control would fire the RadGrid_UpdateCommand event.  Obviously, that code is in the codebehind for the parent aspx page.  What do I need to do in the OnButtonClick event of the user control in order to fire the RadGrid_UpdateCommand event in the parent aspx page?
0
Jeff Snyder
Top achievements
Rank 1
answered on 13 May 2008, 07:12 PM
If the user control is an edit form for a RadGrid, how do I remove the user control from the Controls collection of the parent aspx page and from the parent RadGrid?

I guess it would help if I actually knew what the non-Prometheus version of the toolbar's Cancel command was doing to the user control within the RadGrid...
0
Erjan Gavalji
Telerik team
answered on 14 May 2008, 08:54 AM
Hi Jeff,

I'm sorry I didn't understand the original scenario. Actually you don't have to hide the edit form user control by code. This behavior is internal for RadGrid. All you need to do is set the proper CommandName for the RadToolBarButton.

The RadToolBar1_ButtonClick event handler is needed for the RadToolBar to make a postback. The RadToolBar in the Service Pack release (scheduled for the end of this week) will contain an AutoPostBack property, which will make the need of ButtonClick event handler assignment obsolete.

Please, find attached a demo page I just created.

Let me know if that helps.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 14 May 2008, 01:00 PM
Thanks Erjan.  After trying to execute your example, it looks like I need to add an HttpHandler in my web.comfig.  It also looks like other "Prometheus" controls will need HttpHandlers as well.  Is there a document that describes all of the entries that need to be added to the web.config for the AJAX version of the controls?
0
Erjan Gavalji
Telerik team
answered on 14 May 2008, 01:33 PM
Hi Jeff,

In the example I sent you the control that requires an HttpHandler is RadScriptManager. The control needs the Telerik.Web.UI.WebResource.axd handler. The RadScriptManager page in the RadControls for ASP.NET Ajax Online Documentation contains more information about this specific HttpHandler registration.

Other controls in the suite that need HttpHandlers registered are: RadEditor, RadSpell, RadUpload and RadChart.

FYI, the Smart Tags of the control designers provide verbs for automatic HttpHandler registration.

I hope this helps.

Best regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 14 May 2008, 03:20 PM
Thanks Erjan.  I registered the Http Handler.  When I run your page, I get a JavaScript error on the default.aspx page.  It states that Telerik is undefined.  I have the Telerik.Web.UI dll in the bin folder.  The grid displays but the toolbar buttons do nothing when clicked.
0
Erjan Gavalji
Telerik team
answered on 15 May 2008, 09:19 AM
Hi Jeff,

Are you running the website in IIS7 integrated mode? If so, the HttpHandlers should be manually registered to the <webserver> section of the application configuration file. Unfortunately we still didn't find a way to register the handlers automatically.

You might want to check the Troubleshooting section, it contains some useful information about some setup related problems.

FYI, for the demonstration purpose you can avoid this exact problem by replacing the RadScriptManager instance with a ScriptManager one.

Kind regards,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 15 May 2008, 11:51 AM
Hi Erjan,

I replaced the RadScriptManager last night, hoping that would resolve the issues.  Obviously, the JavaScript error went away.  However, the toolbar buttons still do nothing in your demo code.  A postback does occur, but the user control remains.  Please advise.

Thanks
Jeff
0
Jeff Snyder
Top achievements
Rank 1
answered on 15 May 2008, 12:06 PM
Also, I resolved the issue with the RadScriptManager this morning by looking at the troubleshooting document.  So, we just need to figure out why the toolbar buttons do nothing.
0
Erjan Gavalji
Telerik team
answered on 15 May 2008, 12:10 PM
Hi Jeff,

Are you using the official RadControls for ASP.NET AJAX release? The RadToolBar control was not finished in the Futures build.

Looking forward to your reply,
Erjan Gavalji
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 15 May 2008, 12:12 PM
Ah, that is it.  Yes, I am still using the Futures build.  Thanks for your help and the quick responses!
0
Jeff Snyder
Top achievements
Rank 1
answered on 15 May 2008, 12:19 PM
Hi Erjan,

I just checked my client.net account.  I do not have a link to download the latest version of the AJAX controls.  We just purchased the non-Prometheus suite of products in the pasy 6 months, so we should be eligible for the AJAX controls.  Correct?

Thanks
Jeff
0
Petia
Telerik team
answered on 15 May 2008, 02:39 PM
Hello Jeff Snyder,

I have replied to your question in a separate personal email.

Best wishes,
Petia
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Petia
Telerik team
answered on 15 May 2008, 02:39 PM
Hello Jeff Snyder,

I have replied to your question in a separate personal email.

Best wishes,
Petia
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Jeff Snyder
Top achievements
Rank 1
answered on 15 May 2008, 02:53 PM
Hi Petia,

I have not received the email.

Thanks
Jeff
0
Petia
Telerik team
answered on 15 May 2008, 03:16 PM
Hello Jeff Snyder,

I have resent the email, you might receive it twice. Please make sure the telerik.com domain is whitelisted, as I am sending from an European IP address and sometimes emails get blocked.

Please email petia.mintcheva@telerik.com directly, if you have not received the email within a couple of hours.

Best wishes,
Petia
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
ToolBar
Asked by
Jon Stromer-Galley
Top achievements
Rank 1
Answers by
Erjan Gavalji
Telerik team
Jon Stromer-Galley
Top achievements
Rank 1
Jeff Snyder
Top achievements
Rank 1
Petia
Telerik team
Share this question
or