Meaning, it is not possible to have events for the "extender" I have created? How can I add a multihandleslider(at run time) which is able to handle events?
My situation: I want the multihandleslider to add handles according to the list I get from database. Hence, I must add it during runtime. Also, is it possible to add multihandleslider in markup and add handlers at runtime?
What is the difference between what I have and the example on the above link which adds a button click (client-side) event to a button added at run-time.
Oh dear, u can have handlers for the events of "extender" that u have created, but they should be in the client side (i.e., in Javascript) and not in server side (VB/C#). U could even do this (adding handlers in script) in runtime by injecting the
script as below from ur aspx.vb/cs
protected override void OnPreRender(EventArgs e)
{
base.OnPreRender(e);
var script = new StringBuilder();
script.AppendFormat("function {0}_OnClientValueChanged(sender, eventArgs){{ ", this.UrMultiHandleSliderExtender.ClientID);
script.AppendLine("alert('adasdasd');"); //replace this with wat actually u want to do
script.AppendLine("}");
this.ClientScript.RegisterClientScriptBlock(typeof(AjaxControlToolkit.MultiHandleSliderExtender),
this.UrMultiHandleSliderExtender.ClientID + "OnClientValueChanged", script.ToString(), true);
this.UrMultiHandleSliderExtender.OnClientValueChanged = string.Format("{0}_OnClientValueChanged", UrMultiHandleSliderExtender.ClientID);
}
cgamage
Member
27 Points
17 Posts
Adding event at runtime
Feb 23, 2012 01:40 PM|LINK
I have the below code:
Dim r As Hashtable = Session.Item(SessionKeys
.RHash)
Dim rReverse As Hashtable = Session.Item(SessionKeys
.RReverseHash)
Dim extender As New
MultiHandleSliderExtender
Dim TargetControlTextBox As New
TextBox
TargetControlTextBox.ID =
"TargetControl_TextBox"
PlaceHolderExtender.Controls.Add(TargetControlTextBox)
extender.ID =
"223_multiHandleSliderExtenderTwo"
extender.BehaviorID = extender.ID
extender.Minimum = 0
extender.Maximum = r.Count - 1
extender.Length = 980
ExtenderZoom.minimum = 0
ExtenderZoom.Maximum = r.Count - 1
ExtenderZoom.Length = 980
BoundControlMin.Text = r(Session.Item(
SessionKeys
.TEMP_Start))
BoundControlMax.Text = r(Session.Item(
SessionKeys
.TEMP_End))
extender.TargetControlID = TargetControlTextBox.ID
extender.Orientation =
SliderOrientation
.Horizontal
extender.EnableHandleAnimation =
True
extender.ShowHandleDragStyle =
True
extender.ShowHandleHoverStyle =
True
AddHandler extender.OnClientValueChanged, AddressOf
ClientDragEnd_Extender
This last line doesn't work.
Error: Error 41 'OnClientValueChanged' is not an event of 'AjaxControlToolkit.MultiHandleSliderExtender'
Ramesh T
Contributor
5111 Points
827 Posts
Re: Adding event at runtime
Feb 23, 2012 03:16 PM|LINK
Hello Mate,
Its client side event, u cannot have handler for this in server side.
cgamage
Member
27 Points
17 Posts
Re: Adding event at runtime
Feb 23, 2012 03:44 PM|LINK
Meaning, it is not possible to have events for the "extender" I have created? How can I add a multihandleslider(at run time) which is able to handle events?
My situation: I want the multihandleslider to add handles according to the list I get from database. Hence, I must add it during runtime. Also, is it possible to add multihandleslider in markup and add handlers at runtime?
cgamage
Member
27 Points
17 Posts
Re: Adding event at runtime
Feb 23, 2012 05:24 PM|LINK
Refer to:http://msdn.microsoft.com/en-us/library/y3bwdsh3.aspx#Y2132
What is the difference between what I have and the example on the above link which adds a button click (client-side) event to a button added at run-time.
Ramesh T
Contributor
5111 Points
827 Posts
Re: Adding event at runtime
Feb 23, 2012 09:39 PM|LINK
Oh dear, u can have handlers for the events of "extender" that u have created, but they should be in the client side (i.e., in Javascript) and not in server side (VB/C#). U could even do this (adding handlers in script) in runtime by injecting the script as below from ur aspx.vb/cs
protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); var script = new StringBuilder(); script.AppendFormat("function {0}_OnClientValueChanged(sender, eventArgs){{ ", this.UrMultiHandleSliderExtender.ClientID); script.AppendLine("alert('adasdasd');"); //replace this with wat actually u want to do script.AppendLine("}"); this.ClientScript.RegisterClientScriptBlock(typeof(AjaxControlToolkit.MultiHandleSliderExtender), this.UrMultiHandleSliderExtender.ClientID + "OnClientValueChanged", script.ToString(), true); this.UrMultiHandleSliderExtender.OnClientValueChanged = string.Format("{0}_OnClientValueChanged", UrMultiHandleSliderExtender.ClientID); }chetan.sarod...
All-Star
65739 Points
11138 Posts
Re: Adding event at runtime
Feb 24, 2012 02:37 AM|LINK
Please refer this
http://aspadvice.com/blogs/garbin/archive/2006/10/04/SliderExtender_3A00_-client_2D00_side-events-and-some-bug-fixes.aspx
http://weblogs.asp.net/abdullaabdelhaq/archive/2010/11/21/creating-custom-tooltip-ajax-extender-control.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.