JuiceUI Slider - ValueChanged event not firing - juice-ui

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.

Related

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

WP7 slider strange behavior

I'm developing Windows Phone 7 app. I have slider control on several page. However, when I go to a certain page within my app, all my slider controls in every page behave strangely.
The symptom is that user can only drag the thumb on slider for very short range.
The certain page I mentioned has no problem with code and XAML. Why does it cause ALL sliders to behave wrongly ?
The problem is that using toolkit Gesture will cause Slider to behave strangely. So when start manipulating on Slider, you should disable Gesture listener, then enable it when stop manipulating on Slider.
<Slider Height="84" Name="fixedSlider" ManipulationStarted="disableGestures" ManipulationCompleted="restoreGestures" />
GestureType prevGestureType;
private void disableGestures(object sender, ManipulationStartedEventArgs e)
{
prevGestureType = TouchPanel.EnabledGestures;
TouchPanel.EnabledGestures = GestureType.None;
fixedSlider.IsHitTestVisible = false;
}
private void restoreGestures(object sender, ManipulationCompletedEventArgs e)
{
TouchPanel.EnabledGestures = prevGestureType;
}
Slider class has property SmallChange and if you look on the slider template, you will see, that when user tap on slider - value changes only on the small change. If you want to avoid this, you need to create custom slider behavior.

Update a User Control from another User Control via AJAX

Maybe I'm having a brain fart or something because it seems like this should be pretty simple but how do you update a User Control from another User Control via Ajax?
I have an ASPX page with two user controls and when I trigger a server-side event on one, I want to refresh a grid on the other so it'll update it's data.
I'm using Telerik controls if that helps. Checkbox event on the first User Control causes the RadGrid in the second User Control to Rebind() and I have RadAjaxManager in the ASPX page and RadAjaxManagerProxy in the two User Controls.
First for me Page.DataBind() doesn't work for me.
I declared in UserControl
// Declare a delegate
public delegate void save_CommandEventHandler ();
//Event
save_CommandEventHandler SaveViewChanged public event;
// I run SaveViewChanged() from a click_button but it can run from anywhere
protected void save_Click (object sender, EventArgs e)
{
UpdateDataInDatabase();
SaveViewChanged ();
}
In page.aspx.cs code
protected override void OnInit (EventArgs e)
{
base.OnInit (e);
// UserControle1 is the Id of your UserControl declared in Aspx Page
UserControle1.SaveViewChanged + =
New UserControle.save_CommandEventHandler
(Save_CommandEventHandler);
}
private void save_CommandEventHandler () {
// Reload the gridView gvExpence to see the change operated in the user control
gvExpence.DataSource =DataAcces.getAllCompanyExpence ();
gvExpence.DataBind ();
// update user control 2
usercontrol2.updateView();
}
An async callback will update the control that caused the postback and also any parent controls of its update panel. If your datagrid is not being updated in the browser after an event it would suggest its update method is not being called
Try calling the .update method of the datagrids updatepanel in the checkbox event
You could try using the ajaxRequest or ajaxRequestWithTarget client-side methods of the AjaxManager to initiate an ajax call. More info about these methods can be found on the Telerik's online documentation: http://www.telerik.com/help/aspnet-ajax/ajxclientsideapi.html

Telerik RadAlert back button cache problem

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

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