RadTabStrip On Click Show Prompt - c#

When the user clicks on a tab, I want to fire the radconfirm window to ask them if they want to proceed. Now, I cancel the event, fire radconfirm, and in the callback, if successful, I'm trying to explicitly postback to show the new tab. I tried doing:
//In tabSelecting event on client
e.get_tab().select(); //to select the new tab because I canceled the selection earlier on
sender._postback(e.get_tab()); //to perform the postback
The RadMultiPage gets updated to the new tab's content, but the RadTabStrip does not show me the new tab selected. I see the old tab selected with the new tab's content.
Any ideas?
Thanks.

If you get your hands on the client object of the clicked tab, you can set is as selected using the set_selected method from the client API (see here).

Because I was attaching to tabSelecting, I need to add a boolean in the component to prevent the cancelling of the event the second time, because setting the selected tab was also firing tabSelecting event. That was the fix.

Related

Issue in firing the server side event of rad context menu

Please check the below screen
When the user clicks the first dynamic menu , then the user clicks the context menu the server side event(item_click) is executed.As soon as the user clicks the user clicks the second dynamic menu and then again clicks the context menu first time the server side event (item click) is not executed.After selecting 3-4 times again the context menu hits the server event.
The dynamic menu are filling inside repeater.The code of radcontext menu is below in aspx page:-
the whole inner content changes with the click of every dynamic control menu.This is attached inside placeholder.
Please let me know why the server event of context menu stops firing once we go inside one dynamic control but the client event fires.
-Sulekha
Probably you do not recreate something right. Make sure to create your dynamic controls in the Page_Init event and to provide the same IDs for them each time. If this is not done, server events tend to fail and even the ViewState may not load properly.

Remove or disable ScriptManager.RegisterStartupScript

I have a page where I list several items. Next to each item there is a icon that is linked to the current page, and sends along the item id.
What I do when the page reloads, is I check for the id and if it is there, I delete the item.
After that, I register a popup to fire using ScriptManager.RegisterStartupScript (call it popup A).
The problem is, that if I now add a new item using my add new textbox and button, and then register another script using ScriptManager.RegisterStartupScript (popup B) , the popup A is still fired as the url still contains the ID of the item I previously deleted??
Does anyone know how to disable/remove that popup A ScriptManager.RegisterStartupScript so it wont fire again?

How to tell which control a contextmenustip is associated with?

I have two labels one lblEmail1 and two lblEmal2 each has the same context menu strip associated with it. The contextmenustip has one menu item which is "Send Email" when I right click on either label and you select "Send Email" it goes to the same function to process the request which would be to take the value lblEmail1.Text or lblEmail2.Text and start an email. The problem is I can't figure out how to tell which label initiated the request. Any help would be appreciated.
add an event handler for the menu's opened event
Sender will be which of the labels triggered it.
Store that somewhere, the email menuitem's tag property would be good, or a private variable on the form class.
Then in the Onclick of the menu item test and proceed accordingly.

Moving button stops click event happening

I have a button, contained in a panel, with a click event, that works fine. However when a users presses another button, I need to move this button into another panel (this is actually a panel with a modalpopupextender), so I this code to do so:
newPanel.Controls.Add(buttonPanel)
It all get's moved and looks fine. However now when the button is clicked it doesn't fire the associated event. I have tried re-adding the event in the page_init, with this code
((Button)this.FindControl("serverModalSave")).Command += new CommandEventHandler(modalSave_Click);
But with no luck. How can I get this button to fire it's click event when moved, and why does it stop working when it's moved?
EDIT:
This Button needs to be added to a panel specified by the user at run time, so there is not a way to determine where the button will go in advance.
I could instead of moving this button, create a new one, but because this button is not created in the page_init I am having issues getting that to fire an event either.
Instead of moving the button, have another button on the other panel set to hidden.
Hide the button you wanted to move and show the hidden one when needed.
Moving the control changes the naming hierarchy and now the button can't be found and the click event can't fire.
This is due to how the page life cycle works. Here is a good (if somewhat dated) article about how view state works - if you understand this, you will understand what went wrong.
If you are creating the button in the new panel, when this button is then clicked do you re-create it in the postback ?
You must re-create all controls on each postback see here

Displaying MessageBox when disabled menu item is clicked

I want to display a message box when any person clicks on the menu item which is not enabled I have tried the following coding but it is not displaying the message box.
Coding:
private void updateFineDetailsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (updateFineDetailsToolStripMenuItem.Enabled == true)
{
frmUpdateFineDetails objUpdateFineDetails = new frmUpdateFineDetails();
objUpdateFineDetails.MdiParent = this;
objUpdateFineDetails.Show();
}
else if (updateFineDetailsToolStripMenuItem.Enabled == false)
{
MessageBox.Show("Unauthorized Person");
}
}
By default I have set the enabled status to false and when the form loads I am checking whether the user is administrator, if the user is admin then this menu item will be enabled for all other user who logs into the application the above menu item has to be disabled.
Please note that the above coding does not generate any error, but it does not even display the messagebox as unauthorized person.
Can anybody help me out in performing this task?
Thanks in advance!
The whole idea of disabling a menu item or a button is to prevent the user from interacting with it. Typically the control will also be rendered in a way so that this becomes clear to the user. If you want to prevent the user from taking certain actions, for instance based on whether the user is an administrator or not, you can use one of three approaches:
Keep the control enabled and inform unauthorized users that the function is not available if he or she invokes it
Disable the control
Hide the control
In the later two cases there is no interaction, since the user cannot invoke the command. I usually tend to prefer to hide the command, if the access to it is role based (meaning that if I don't have access to the command when I start the application, it will not happen at any point while running it), or disabling it if the availability of the command is related to data state.
As I understand, a disabled menu item does not raise Click events.
If you need to display the error message then enable the menu item.
If admin clicks then default action occurs and if other users click show a message box and prevent the default action.
From your code I think you can do this just by enabling the menu item.
Disabling a menu item isn't a cosmetic display issue, it does just what you'd expect from the term - it disables the menu item.
When disabled, the menu item is effectively inert - it will not raise the click event, and there's no (straightforward) way to make it do so.
I can guess at your motivations - to explain to your users why the particular menu item is unavailable to them - but you'll need to find a different approach, one that works with the system, not against it.
Some possible approaches ...
Leave the menu item disabled, allowing the user to select it - you can then make a role based choice on how to handle the event.
Disable the menu item and provide feedback elsewhere in your UI telling the user what level of access they have.
Display a tooltip with the reason for disabling the control
Leave the menu item enabled, but change it's display to look inactive (this is hard to achieve 100%); this will allow the events to fire and your handler to be invoked
Create a separate "Explain" menu item, perhaps on the "Help" menu; when invoked, all disabled menu items become enabled, and will explain to the user why the command is unavailable.
Some systems display a line of help text relevant to the highlighted menu item on the status bar - you could leverage this to explain availability: "Maintain customer details (requires Administrator role)"
a disabled control does not raise Click events. you should simulate that state! for example:
enable menu item
change menu item's forecolor to SystemColors.GrayText
save state of item in item's tag (enable or disable)
if click event raised, first check item's tag
change menu item's forecolor to normal fore color if enabled item.

Categories