Hi!
I've got a problem with the onclientslide function. What I am trying to do is set the value of the slider in a label. The problem is that the slider and the label are in the PagerTemplate of an gridview.
So when the gridview has only 1 page, the pagertemplate doesn't exist. I can add the javascript function in codebehind and that works fine for a normal page.
But my gridview is in an updatepanel which is in a usercontrol. The first time when the whole page is rendered, the gridview is empty so there is no pagertemplate, after i search the results will be shown in the gridview and the gridview has a pager template. But because it's an async postback, the whole page doesn't render and i cant register javascrip, so the function will not work.
this is my pagertemplate inside the gridview control
This is the function where i try to add the javascript to the slider
I've got a problem with the onclientslide function. What I am trying to do is set the value of the slider in a label. The problem is that the slider and the label are in the PagerTemplate of an gridview.
So when the gridview has only 1 page, the pagertemplate doesn't exist. I can add the javascript function in codebehind and that works fine for a normal page.
But my gridview is in an updatepanel which is in a usercontrol. The first time when the whole page is rendered, the gridview is empty so there is no pagertemplate, after i search the results will be shown in the gridview and the gridview has a pager template. But because it's an async postback, the whole page doesn't render and i cant register javascrip, so the function will not work.
this is my pagertemplate inside the gridview control
| <PagerTemplate> |
| <telerik:RadSlider ID="slider" runat="server" Orientation="Horizontal" Skin="Office2007" |
| AutoPostBack="true" OnValueChanged="Slide_Changed" DataValueField="lblpage" OnClientSlide="clientSlide" /> |
| <label>Pagina </label> |
| <asp:Label ID="SlideLabel" runat="server" /> |
| <asp:Label ID="lblpage" runat="server" Text='<%# " van " + ItemsGridView.PageCount %>' /> |
| </PagerTemplate> |
This is the function where i try to add the javascript to the slider
| protected void ItemsGridView_DataBound(object sender, EventArgs e) |
| { |
| GridViewRow rowPager = ItemsGridView.BottomPagerRow; |
| if (rowPager != null) |
| { |
| RadSlider slider = (RadSlider)rowPager.Cells[0].FindControl("slider"); |
| slider.MinimumValue = 1; |
| slider.MaximumValue = ItemsGridView.PageCount; |
| slider.Value = ItemsGridView.PageIndex + 1; |
| Label sliderLabel = (Label)rowPager.Cells[0].FindControl("SlideLabel"); |
| sliderLabel.Text = (ItemsGridView.PageIndex + 1).ToString(); |
| string script = @" |
| <script type='text/javascript'> |
| function clientSlide(sender, eventArgs) |
| { |
| var myLabel = document.getElementById('" + sliderLabel.ClientID + @"'); |
| myLabel.innerHTML = sender.get_value(); |
| } |
| </script>"; |
| Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "clientslider", script); |
| slider.OnClientSlide = "clientSlide"; |
| } |