Telerik RadAlert back button cache problem - telerik

I'm sure you have had this one before so if you could point me to something similar....
I have a server side creation of a RadAlert window using the usual Sys.Application.remove_load and add_load procedure however the alert keeps popping up as it seems to be caching when the user hits the back button after it has been activated. I have tried to put a onclick event on a button to clear the function using remove_load before it moves to the next page however it still doesn't seem to clear it.
Its used in validation so if a user inputs failed validation it pops up. If they then go and enter correct validation it then moves onto the next page. If they then use back button this is where it pops up again. Any ideas?
Server side:
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
btnSearch.Attributes.Add("onclick", "Sys.Application.remove_load(f);");
}
}
private void btnSearch_Click(object sender, System.EventArgs e)
{
string radalertscript = "(function(){var f = function(){radalert('Welcome to RadWindow Prometheus!', 330, 210); Sys.Application.remove_load(f);};Sys.Application.add_load(f);})()";
RadAjaxManager1.ResponseScripts.Add(radalertscript);
}
Ive also tried using
RadAjaxManager1.ResponseScripts.Clear();
before it moves on to the next page on the postback event

What lingvomir says is correct. What I would suggest as a solution is to ajaxify that Search Button.
e.g.
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Button1" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadWindowManager ID="RadWindowManager1" runat="server">
</telerik:RadWindowManager>
<asp:Button ID="Button1" runat="server" Text="show radalert" OnClick="Button1_Click" /><br />
and in codebehind:
protected void Button1_Click(object sender, EventArgs e)
{
string radalertscript = "radalert('Welcome to RadWindow Prometheus!',330,210);";
RadAjaxManager1.ResponseScripts.Add(radalertscript);
}

I don't think the problem is with the radalert() function - You will get the same behavior if you use the normal browser alert() as well. The Sys.Application.Load event is raised each time the page is loaded in the browser - including when you use the back button to open it again. If the code that adds the radalert() is also on the page, it will run as well and the alert will be displayed during Load.

You need an intermediate page that loads the client version of the
alert, the callback function could then navigate to the correct page
using location.replace(...) - using location.replace will remove this intermediate alerting page from history
hope that helps

Related

Navigate to another page on button click

I am developed the Windows mobile application I've added the button for VS blend 2015 , but there's no button navigate to option how to bind to my button for the page sub.xaml
<Button x:Name="button" Content="Enter" Height="42" Margin="122,-113,0,0"
VerticalAlignment="Top" Width="144" Foreground="#FF50CBC5"
Background="#FF0F0E0E" HorizontalAlignment="Left"/>
The hyperlink button gives you the option to navigate to another page onclick.
This screen shot is from Blend.
So change your mark up as follows, including the generated Click handler.
<HyperlinkButton x:Name="button" Click="HyperlinkButton_Click"
Content="Enter" Height="42" Margin="122,-113,0,0"
VerticalAlignment="Top" Width="144" Foreground="#FF50CBC5"
Background="#FF0F0E0E" HorizontalAlignment="Left"/>
Then in your cs, you need to direct the navigation.
// Button to navigate to sub.xaml page.
private void HyperlinkButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
// Navigate back to sub.xaml page.
this.Frame.Navigate(typeof(SubPage));
}
You will have a Click event for button. In that click event, write the code as
private void Button_Click(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/sub.xaml", UriKind.RelativeOrAbsolute));
}
You can do this using following steps.
1st Step - add a new button on your window and change the properties as you wish.
2nd Step - double click on that button. then you will go to the cs file like this.
private void Button_Click(object sender, RoutedEventArgs e)
{
}
3rd Step - create new object of window that you want to navigate and open that, then close current window
private void Button_Click(object sender, RoutedEventArgs e)
{
NewWindow newWindow = new NewWindow();
newWindow.Show();
this.Close();
}
Thanks.

How to reset telerik dropdownlist control value on client side

I want to reset dropdownlist selection on clear button click and set default message.
<telerik:RadDropDownList ID="radDrpDwn_User" runat="server" Width="325px" DefaultMessage="--select--">
</telerik:RadDropDownList>
First of all there isn't any control in telerik called (RadDropDownList) , the compatible control is RadComboBox control
so you define it using the Following ;
<telerik:RadComboBox ID="radDrpDwn_User" runat="server" Width="325px" DefaultMessage="--select--">
</telerik:RadComboBox>
and in the clear Button :
protected void Clear_Click(object sender,EventArgs e)
{
radDrpDwn_User.ClearSelection();
}
regards

JuiceUI Slider - ValueChanged event not firing

I'm trying to include a JuiceUI Slider control inside a ASP.NET GridView control where each row will have a unique slider control. As a test I created a Slider control:
<juice:slider ID="MasterThresholdSlider" Value="50" Min="0" Max="100" runat="server"
Step="25" ValueChanged="MasterThresholdSlider_ValueChanged"></juice:slider>
<asp:TextBox ID="MasterThresholdText" runat="server"></asp:TextBox>
Now from the documentation I have read, I can detect the value being changed when the ValueChanged event is raised. So in the code behind I have created the following:
protected void MasterThresholdSlider_ValueChanged(object sender, EventArgs e)
{
Juice.Slider slider = (Juice.Slider)sender;
MasterThresholdText.Text = slider.Value.ToString();
}
For some reason the event doesn't fire when I run the application (breakpoint is at the beginning of the event). Anyone know what I'm doing wrong?
You'll need to add AutoPostBack="true" to the juice:slider control to initiate an autopostback. Otherwise that event won't fire until something else on the page triggers a postback.

Umbraco switching to https and calling a code behind event on login

Have the below code to switch requests from ‘http’ to ‘https’ when user clicks on a button. This is to protect user/password info before it is sent to the server. In the server, should call the code behind associated to the button but is not doing it. On pages that are NOT under Umbraco this code works fine.
Control:
<asp:ImageButton ID="btnLogin" runat="server" OnClick="btnLogin_Click" ... />
Code behind:
protected void Page_Load(object sender, EventArgs e)
{
PostBackOptions pbOptions = new PostBackOptions(btnLogin);
pbOptions.ActionUrl = Request.Url.ToString().Replace("http://", "https://");
btnLogin.Attributes.Add("onclick", "this.disabled = true; + Page.ClientScript.GetPostBackEventReference(pbOptions) + ";");
}
protected void btnLogin_Click(object sender, ImageClickEventArgs e)
{
want to execute that code
}
If put this code in an Umbraco page, when click on the login button the request changes to ‘https’, page is post to the server but the btnLogin_Click event is NOT called.
Is there something need to change to make this work in Umbraco? Does anybody know a solution / work around to make ‘btnLogin_Click’ to be executed? Or any idea where I can look to find the problem?
Thanks
Have you tried adding in your Page_Load:
btnLogin_Click += new ImageClickEventHandler(btnLogin_Click);
You may need to add this, as unless you have AutoEventWireup="true" specified in your usercontrol/masterpage declaration, it won't be automatically fired on postback.
HTH,
Benjamin

Problem with ajax modal popup extender

I have a Button which is having modalpopupextender which is working absolutely fine no problem at all, but before the modalpopup appears i want to validated text box control if it is not valid then modalpopup should not appear other wise it should work as usual..
does anybody having idea.
We use following function. On the button click you can call this function. This will validate validation group that is passed to this function and it is work will pop the modal popup otherwise validation error will appear.
function ClientSideValidate(modalId,group)
{
var modal = $find(modalId);
Page_ClientValidate(group);
if(!Page_IsValid)
{
modal.show();
}
}
Something I've done in the past is manually show/hide the modal popup. I realize the ModalPopupExtender control requires a target, so you'll need a dummy target which will remain inactive:
<asp:LinkButton id="btnDummyTarget" runat="server" />
<asp:Button
id="btnActualButtonTiedToValidation"
ValidationGroup="SomeValidationGroup"
OnClick="MyButton_Click"
runat="server" />
<ajaxToolkit:ModalPopupExtender
id="mpeMyPopup"
PopupControlID="pnlSomePanelToShow"
TargetControlID="btnDummyTarget"
runat="server" />
Then, in your codebehind you can do the following:
protected void MyButton_Click(object sender, EventArgs e)
{
if(Page.IsValid)
mpeMyPopupExtender.Show();
}
This is also handy for delete confirmation dialogs.

Resources