Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
100 views
Hey Guys,

I've followed one of the forum topics on here in respect of disabling AJAX for a specific postback. Basically I have a button on a page that creates a PDF file. Because the routine is modifying the response and adding response headers, AJAX failed to work. So this is what I've done:

ASPX Page:

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" EnableAJAX="true" UpdatePanelsRenderMode="Inline" ClientEvents-OnRequestStart="onRequestStart">
<%-- AJAX EVENTS GOES HERE --%>
</telerik:RadAjaxManager>

The ClientEvents-OnRequestStart javascript script looks like this:

function onRequestStart(ajaxManager, eventArgs) {
            if (eventArgs.EventTarget == "ctl00$ContentPlaceHolder1$btnMainExportToPDF") {
                eventArgs.set_enableAjax(false);
                document.getElementById("<%= btnMainExportToPDF.ClientID %>").style.display = "none";
                document.getElementById("<%= imgExportLoader.ClientID %>").style.display = "";
            }
        }

On the server side I have this:

protected void btnMainExportToPDF_Click(object sender, EventArgs e)
    {
        string transDateStart = "";
        string transDateEnd = "";
        if (dtTransDateStart.SelectedDate.HasValue && dtTransDateEnd.SelectedDate.HasValue)
        {
            transDateStart = string.Format("{0}-{1}-{2}", dtTransDateStart.SelectedDate.Value.Year.ToString(), dtTransDateStart.SelectedDate.Value.Month.ToString().PadLeft(2, '0'), dtTransDateStart.SelectedDate.Value.Day.ToString().PadLeft(2, '0'));
            transDateEnd = string.Format("{0}-{1}-{2}", dtTransDateEnd.SelectedDate.Value.AddDays(1).Year.ToString(), dtTransDateEnd.SelectedDate.Value.AddDays(1).Month.ToString().PadLeft(2, '0'), dtTransDateEnd.SelectedDate.Value.AddDays(1).Day.ToString().PadLeft(2, '0'));
        }
 
        string storeID = hfActiveSelectedStoreID.Value;
        string pageRequestURL = string.Format("ReportsPrint-GlobalSpendHistory.aspx?TS={0}&TE={1}&SI={2}", NecBase.Encryption(transDateStart), NecBase.Encryption(transDateEnd), NecBase.Encryption(storeID));
 
        string gridQuery = GetMainGridQuery(false);
        Session["mainGridQuery"] = NecBase.Encryption(gridQuery);
 
        //Also add to Session: Master Category, Sub Category, Products
        IList<RadComboBoxItem> selMasterCategories = cboMainCategories.CheckedItems;
        IList<RadComboBoxItem> selSubCategories = cboSubCategories.CheckedItems;
        //IList<RadComboBoxItem> selProducts = cboProducts.CheckedItems;
 
        Session["selMasterCats"] = GetStringArrayFromIList(selMasterCategories);
        Session["selSubCats"] = GetStringArrayFromIList(selSubCategories);
        //Session["selProducts"] = GetStringArrayFromIList(selProducts);
 
        StringWriter sWriter = new StringWriter();
        Server.Execute(pageRequestURL, sWriter);
 
        string htmlCodeToConvert = sWriter.GetStringBuilder().ToString();
 
        PdfConverter pdfConverter = new PdfConverter();
        pdfConverter.LicenseKey = ConfigurationManager.AppSettings["EvoPdfKey"].ToString();
        pdfConverter.HtmlViewerWidth = 793;
 
        pdfConverter.PdfDocumentOptions.PdfPageSize = PdfPageSize.A4;
        pdfConverter.PdfDocumentOptions.PdfPageOrientation = PdfPageOrientation.Portrait;
        pdfConverter.PdfDocumentOptions.PdfCompressionLevel = PdfCompressionLevel.Normal;
        pdfConverter.PdfDocumentOptions.ShowHeader = false;
        pdfConverter.PdfDocumentOptions.ShowFooter = false;
        pdfConverter.PdfDocumentOptions.FitWidth = true;
 
        pdfConverter.PdfDocumentOptions.EmbedFonts = true;
        pdfConverter.PdfDocumentOptions.LiveUrlsEnabled = true;
 
        pdfConverter.JavaScriptEnabled = true;
        pdfConverter.PdfDocumentOptions.JpegCompressionEnabled = true;
 
        byte[] pdfBytes = pdfConverter.GetPdfBytesFromHtmlString(htmlCodeToConvert.ToString());
 
        string fileName = string.Format("SpendHistoryReport_{0}{1}{2}", DateTime.Today.Date.Day.ToString(), DateTime.Today.Date.Month.ToString(), DateTime.Today.Date.Year.ToString());
 
        HttpResponse response = HttpContext.Current.Response;
        response.Clear();
        response.AddHeader("Content-Disposition", string.Format("attachment; filename={0}.pdf; size={1}", fileName, pdfBytes.Length.ToString()));
        response.BinaryWrite(pdfBytes);
        response.End();
    }

My question now is, after the server code has executed, I need to re-enable the controls which I just disabled using the Javascript script. I have tried using the ScriptManager.RegisterStartupScript but the javascript never gets called. How can I re-enable the controls after the entire routine has finished executing?

The javascript script I'm using to re-enable the controls looks like this:

function reEnableControl() {
            alert('test');
            document.getElementById("<%= imgExportLoader.ClientID %>").style.display = "none";
            document.getElementById("<%= btnMainExportToPDF.ClientID %>").style.display = "";
        }

The alert box is never shown either. I need to re-enable the controls so that the user can continue selecting other filters or re-export the document if they choose to do so. Since the code modifies the response headers, I cannot ajaxify the button control and use a loading panel instead. Any ideas or thoughts?

The reason why I'm hiding the controls is so that the user is aware that there is activity at that point in time after clicking the button.
Angel Petrov
Telerik team
 answered on 29 Nov 2012
9 answers
208 views
In month view I need to detect if the next month or previous month arrow has been clicked. No big deal right? I just do it in the OnNavigationCommand event of RadScheduler with something like:

if (e.Command == SchedulerNavigationCommand.NavigateToNextPeriod)

And that works fine. The issue is that I need to set a flag in this case before the TimeSlotCreated event fires. However, in some cases, (usually the first time I click on the next month arrow) the TimeSlotCreated event fires before the OnNavigationCommand event so my flag is not set and my code bombs.

Can anyone thing of a work around for me? Much appreciated!

Dan
Plamen
Telerik team
 answered on 29 Nov 2012
6 answers
185 views
I have my slider inside of a parent container whose display I am toggling with jQuery.  This works correctly in Firefox, slightly less correctly in IE8, and not at all in Google Chrome.  I found this post which said this issue was fixed in the newest release, but I'm guessing that fix was only for Firefox: http://www.telerik.com/community/forums/aspnet-ajax/slider/radslider-bind-it-in-a-repeater.aspx.

In Chrome all that renders is:
<div id="RadSlider1" class="RadSlider RadSlider_Vista " style="height:40px;width:400px;"> 
    <input id="RadSlider1_ClientState" name="RadSlider1_ClientState" type="hidden" /> 
</div>  


Here's my simple test case (nothing in the code behind), you can see that the slider in the toggled div never shows up (remember to test in Chrome):

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test2.aspx.cs" Inherits="Test2" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title>Untitled Page</title> 
 
    <script src="scripts/jquery.js" language="javascript"></script> 
 
    <script language="javascript" type="text/javascript"> 
        $(document).ready(function(){ 
            $("#showHiddenDiv").click(function(){ 
                $("#hiddenFromStart").toggle(); 
            }); 
        }); 
    </script> 
 
</head> 
<body> 
    <form runat="server"> 
    <asp:ScriptManager runat="server" ID="uxScriptManager"> 
    </asp:ScriptManager> 
    <telerik:RadSlider runat="server" ID="uxFilterSlider" Orientation="Horizontal" ItemType="Item" 
        Width="400" TrackPosition="Center" Skin="Vista" Height="40" TrackMouseWheel="true"> 
        <Items> 
            <telerik:RadSliderItem runat="server" Text="None" Value="0" /> 
            <telerik:RadSliderItem runat="server" Text="Very Easy" Value="1" /> 
            <telerik:RadSliderItem runat="server" Text="Easy" Value="2" /> 
            <telerik:RadSliderItem runat="server" Text="Medium" Value="3" /> 
            <telerik:RadSliderItem runat="server" Text="Hard" Value="4" /> 
        </Items> 
    </telerik:RadSlider> 
    <a id="showHiddenDiv" style="cursor: pointer;">Show Hidden Slider</a> 
    <div id="hiddenFromStart" style="display: none;"> 
        I was hidden! 
        <telerik:RadSlider runat="server" ID="RadSlider1" Orientation="Horizontal" ItemType="Item" 
            Width="400" TrackPosition="Center" Skin="Vista" Height="40" TrackMouseWheel="true"> 
            <Items> 
                <telerik:RadSliderItem runat="server" Text="None" Value="0" /> 
                <telerik:RadSliderItem runat="server" Text="Very Easy" Value="1" /> 
                <telerik:RadSliderItem runat="server" Text="Easy" Value="2" /> 
                <telerik:RadSliderItem runat="server" Text="Medium" Value="3" /> 
                <telerik:RadSliderItem runat="server" Text="Hard" Value="4" /> 
            </Items> 
        </telerik:RadSlider> 
    </div> 
    </form> 
</body> 
</html> 
 



Note: The OnClientLoaded "fix" didn't work for Chrome and was unnecessary for the other two browsers.

Slav
Telerik team
 answered on 29 Nov 2012
2 answers
322 views
hi kindly help me .,in range  date filter in radgrid  .i made a function to make filter when the user hit enter key and its working fine .
my problem is (i made when the popup closing set focus on date input to make user hit enter to filter date )
date picker (showpoupnfoucs=true)  to show popup when the user focus on the date input .
it's working fine but in IE the popup not hide after selecting date ;
here is the focus function 
    function onDatePickerOnPopupClosing(sender, eventArgs) {
                //get the date input text box
                  sender.get_dateInput().focus();
             }
why it's not working with IE otherwise works with other browser !!!!!!!
i should make both (set focus when the user select date and showpoupnfoucs=true)
Ashraf
Top achievements
Rank 2
 answered on 29 Nov 2012
1 answer
132 views
Hi,

The slider with previous releases has worked perfectly for me. However, since I updated to the latest Telerik release, as soon as I start to drag the slider, the browser pops up a "Microsoft JScript Runtime Error: Invalid arguments" error box. The problem only happens when I drag the marker. If I click on a different part of the slider, the marker moves to the clicked position fine.

When I tried to debug the problem, the debugger shows the following code:

...onDragStart:function(v){var r=v.element;
if(r===this._selectedRegionElement){return this._onDragStartRange(v);
}var k=parseInt($telerik.getCurrentStyle(r,"left",0));
if(isNaN(parseInt(r.style.left))){r.style.left=k+"px";
}var f=parseInt($telerik.getCurrentStyle(r,"top",0));
if(isNaN(parseInt(r.style.top))){r.style.top=f+"px";
}...

And the problem happens in the highlighted line. The value of "$telerik.getCurrentStyle(r,"left",0)" is "auto", and "r.style.left" is "". So you can see where the problem is. Any suggestions?

Thanks
Ning
Slav
Telerik team
 answered on 29 Nov 2012
8 answers
256 views
Hello Community,

i hope you can help me.

Is it possible to use my own Textbox for RadMonthYearPicker?

I need this because i have some css classes that not work with the default textbox of the RadMonthYear Control.
Or i don't know how.

I'm thankful for any Idea!
Danny
Daniel
Top achievements
Rank 1
 answered on 29 Nov 2012
3 answers
97 views
Hi I am trying to display a file from an uploaded file using the RadUpload Control. I want to click on an imagebutton where it will display the file that was uploaded. Is this possible?
Plamen
Telerik team
 answered on 29 Nov 2012
5 answers
216 views
Hey guys,

I have a radgrid with grouping enabled. The data source I use for the grid comes sorted from the db, using a more complicated algorithm.

However, the radgrid re-sorts my data, messing up the initial order.

Any ways to prevent that?

PS: I am using version 2012.2.904.40

Thanks!
Martin
Telerik team
 answered on 29 Nov 2012
1 answer
209 views
Hi,

I have radtool bar on page header. It will have only three toolbar items. I want first two align to left and third one to right. The tool bar occupies entire page width (100%). How to align items?

I have something like below all the items are aligned to left.

        <telerik:RadToolBar runat="server" ID="RadToolBar1" Skin="Hay" Width="100%">
            <Items>
                <telerik:RadToolBarButton ImageUrl="someimage.jpg"></telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text="Application TITLE" Checked="true" CheckOnClick="true" AllowSelfUnCheck="false"></telerik:RadToolBarButton>
                <telerik:RadToolBarButton Text="Getout" ></telerik:RadToolBarButton>
            </Items>
        </telerik:RadToolBar>
Princy
Top achievements
Rank 2
 answered on 29 Nov 2012
4 answers
192 views
Hi,

I am working on a project and I want to change the forecolor of the first three rows of the radgrid and also make it bold so as to show that those top three records are the leading results in the radgrid.

Please help with how I can achieve this.

Thanks
Princy
Top achievements
Rank 2
 answered on 29 Nov 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Dean
Top achievements
Rank 1
Leland
Top achievements
Rank 2
Iron
Iron
Iron
Emil
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?