Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
204 views

Some of our users asked me if it is possible to format the html-code for better readability, some of the content was stored without newlines in the database and results in a pain to read in the html-mode when they need to make some minor changes. 

I'm not looking for something advanced more or less only some indentation and newlines.
Did not find anything useful when searching for this.. 

Alien Interactive AB
Top achievements
Rank 1
 answered on 24 Mar 2021
6 answers
133 views

Hi all, I have a strange problem that I hope will have a simple solution.

I have a RadGrid in an asp.net webform.  This grid shows a list of reports that can be downloaded.

I have created a RadButtonColumn and set its CommandName to GetReport.

I am checking the ItemCommand event for this name and it is firing.

However the routine I am using to retrieve the PDF is not displaying the file for download.

 

If I put the same routine into a generic .net button, it fires without issue and acts as is expected.

 

See attached form structure and code behind.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="FrmLotRegister.aspx.cs" Inherits="FrmLotRegister" Trace="false" EnableSessionState="False" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <asp:SqlDataSource SelectCommand="SELECT DISTINCT Product, Binder, Date_Produced, Customer, Project, Location, Lot, Category, Job, Nata FROM View_Sample_Register WHERE (Nata > 0) AND (Product <> 'NULL')" ConnectionString="<%$ ConnectionStrings:TestConnectionString %>" ProviderName="System.Data.SqlClient" ID="DataSource1" runat="server" ></asp:SqlDataSource>
        <telerik:RadGrid ID="RadGrid1" runat="server" ShowGroupPanel="True" DataSourceID="DataSource1"
        AllowSorting="True" AllowPaging="True" AllowFiltering="True" AllowFilteringByColumn="True" EnableLinqExpressions="False" OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender" Skin="Black" AllowAutomaticUpdates="True">
            <MasterTableView GroupLoadMode="server" ShowGroupFooter="True" GroupsDefaultExpanded="False" AutoGenerateColumns="False">
                <Columns>
                    <telerik:GridBoundColumn DataField="Date_Produced" DataType="System.DateTime" FilterControlAltText="Filter Date_Produced column" HeaderText="Date_Produced" SortExpression="Date_Produced" UniqueName="Date_Produced">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Project" FilterControlAltText="Filter Project column" HeaderText="Project" SortExpression="Project" UniqueName="Project">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Job" FilterControlAltText="Filter Job column" HeaderText="Job" SortExpression="Job" UniqueName="Job">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Lot" FilterControlAltText="Filter Lot column" HeaderText="Lot" SortExpression="Lot" UniqueName="Lot">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Location" FilterControlAltText="Filter Location column" HeaderText="Location" SortExpression="Location" UniqueName="Location">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Product" FilterControlAltText="Filter Product column" HeaderText="Product" SortExpression="Product" UniqueName="Product">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Binder" FilterControlAltText="Filter Binder column" HeaderText="Binder" SortExpression="Binder" UniqueName="Binder">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Customer" FilterControlAltText="Filter Customer column" HeaderText="Customer" SortExpression="Customer" UniqueName="Customer">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Category" FilterControlAltText="Filter Category column" HeaderText="Category" SortExpression="Category" UniqueName="Category">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Nata" DataType="System.Int32" FilterControlAltText="Filter Nata column" HeaderText="Nata" SortExpression="Nata" UniqueName="Nata">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn ButtonType="PushButton" CommandName="GetReport" DataTextField="Nata" FilterControlAltText="Filter column column" HeaderText="Report" UniqueName="column" CommandArgument="GetReport">
                    </telerik:GridButtonColumn>
                </Columns>
                <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Job" FieldName="Job" FormatString="" HeaderText="" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldAlias="Job" FieldName="Job" FormatString="" HeaderText="" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="Lot" FieldName="Lot" FormatString="" HeaderText="" />
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldAlias="Lot" FieldName="Lot" FormatString="" HeaderText="" />
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                </GroupByExpressions>
            </MasterTableView>
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
 
            <ClientSettings AllowDragToGroup="True">
            </ClientSettings>
        </telerik:RadGrid>
    </div>
        <p>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
        </p>
    </form>
</body>
</html>

 

and the code behind

 

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using LabassistEngineerPortal.Data;
using System.Linq;
 
public partial class FrmLotRegister : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
 
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        //On first run sort only to show the last month
        if (!Page.IsPostBack)
        {
            RadGrid1.MasterTableView.FilterExpression = "([Date_Produced] > '" + DateTime.Today.AddMonths(-1).ToShortDateString() + "') ";
 
            GridColumn column = RadGrid1.MasterTableView.GetColumnSafe("Date_Produced");
            column.CurrentFilterFunction = GridKnownFunction.GreaterThanOrEqualTo;
            column.CurrentFilterValue = DateTime.Today.AddMonths(-1).ToShortDateString();
            RadGrid1.GroupingEnabled = true;
            RadGrid1.MasterTableView.Rebind();
 
        }
 
 
    }
    //Take a Byte[] and turn it into a PDF for user download
    protected void Send_PDF(byte[] File, string Filename)
    {
        byte[] pdfdata = File;
        try
        {
            Response.Clear();
            Response.ContentType = "application/pdf";
 
            Response.BinaryWrite(pdfdata);
            string F = @"attachment;filename=""" + Filename + @"""";
            Response.AddHeader("content-disposition", F);
 
 
            Response.Cache.SetExpires(DateTime.Now.AddDays(7));
            Response.Cache.SetCacheability(HttpCacheability.Public);
            Response.Cache.SetValidUntilExpires(true);
             
            Response.End();
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }
 
    //The same routine is used in the RadButtonColumn control.
    //The routine fires but will not send the PDF at the end
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        //if button commandname is GetReport then fire this generic test function
        if (e.CommandName == "GetReport")
        {
            int? N = 4511;
            LabDatabase db = new LabDatabase();
            View_Sample_Register s = new View_Sample_Register();
            s = db.View_Sample_Register.FirstOrDefault(x => x.Nata == N);
            Nata_Reports r = new Nata_Reports();
            r = db.Nata_Reports.OrderByDescending(x => x.Revision).First(x => x.Nata_No.Value == N);
            string filename = s.Date_Produced.Value.Day + "-" + s.Date_Produced.Value.Month + "-" + s.Date_Produced.Value.Year + " " + s.Product + "-" + s.Binder + " " + s.Category + " " + r.Nata_No + ".pdf";
 
            Send_PDF(r.Report, filename);
 
        }
    }
 
    //when traditional .net button is used this routine works fine.
    protected void Button1_Click(object sender, EventArgs e)
    {
        int? N = 4511;
        LabDatabase db = new LabDatabase();
        View_Sample_Register s = new View_Sample_Register();
        s = db.View_Sample_Register.FirstOrDefault(x => x.Nata == N);
        Nata_Reports r = new Nata_Reports();
        r = db.Nata_Reports.OrderByDescending(x => x.Revision).First(x => x.Nata_No.Value == N);
        string filename = s.Date_Produced.Value.Day + "-" + s.Date_Produced.Value.Month + "-" + s.Date_Produced.Value.Year + " " + s.Product + "-" + s.Binder + " " + s.Category + " " + r.Nata_No + ".pdf";
 
        Send_PDF(r.Report, filename);
    }
}

 

What am I doing wrong here?  Why can I not seem to retrieve a file using the Gridviews buttonColumn?

 

kieran
Top achievements
Rank 2
 answered on 24 Mar 2021
2 answers
8.0K+ views

Hello,

I have a legacy .NET web forms application with targetFramework 4.6.2.

I need to install Telerik.Web.UI  and Telerik.Web.UI.Skims.dll for this application. Please direct me from what location should I download the dll. I looked in Nuget but unable to find the dll

 

Thanks

Kapil 

Doncho
Telerik team
 answered on 23 Mar 2021
5 answers
1.3K+ views
Hi all:

I am working with this example:

http://demos.telerik.com/aspnet-ajax/upload/examples/async/webmail/defaultcs.aspx?product=asyncupload

However I do not understand how to read the file data from the uploaded files. I need to read the files into a byte array. Here is the code:

PopulateUploadedFilesList();
if (UploadedFiles != null)
{
  AttachmentRepeater.DataSource = UploadedFiles;
  AttachmentRepeater.DataBind();
  for (int i = 0; i<UploadedFiles.Count; i++)
  {
       #region get file content
       // Open a file and read the contents into a byte array.
       FileStream stream = File.OpenRead(UploadedFiles[i].FileName);
       byte[] byteData = new byte[stream.Length];
       stream.Read(byteData, 0, byteData.Length);
       stream.Close();
       // Encode the data using base64.
       string encodedData = System.Convert.ToBase64String(byteData);
     }
  }

Any and all help is greatly appreciated.

John.
Vessy
Telerik team
 answered on 23 Mar 2021
1 answer
132 views

Dear Sirs or Madams,

just for your information: On your website "https://demos.telerik.com/responsive-web-design-aspnet/samples/adaptive/media-player.aspx", the video-source is currently not available.

Kind Regards.

Vessy
Telerik team
 answered on 22 Mar 2021
9 answers
260 views

Hello, I have two grids on the same page in batch edit mode. When I submit a page via javascript code the second grid has command type of "Update" instead of "Insert". Please help!

<div class="grid__col grid__col--1-of-2">
                <p>Prescriptions</p>
                <telerik:RadGrid ID="gridPrescriptions" runat="server" AutoGenerateColumns="false"
                    AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowSorting="True" AllowPaging="True"
                    OnNeedDataSource="gridPrescriptions_NeedDataSource" Width="100%" DataKeyNames="EscalationCaseRxId"
                    OnBatchEditCommand="gridPrescriptions_BatchEditCommand">
                    <MasterTableView CommandItemDisplay="Top" EditMode="Batch">
                        <BatchEditingSettings EditType="Row" />
                        <CommandItemSettings ShowSaveChangesButton="false" ShowRefreshButton="false" ShowCancelChangesButton="false" />
                        <Columns>
                            <telerik:GridBoundColumn DataField="RxNumber" HeaderText="Prescription Number *" UniqueName="RxNumber" MaxLength="50" HeaderStyle-Width="300">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                    </RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridBoundColumn>
                            <telerik:GridDateTimeColumn DataField="DateOfService" HeaderText="Date of Service *" UniqueName="DateOfService" HeaderStyle-Width="400" DataFormatString="{0:MM/dd/yyyy}">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                    </RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridDateTimeColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>
            </div>
 
            <div class="grid__col grid__col--1-of-2">
                <p>Benefit Verification</p>
                <telerik:RadGrid ID="gridBenefitVerification" runat="server" AutoGenerateColumns="false"
                    AllowAutomaticInserts="true" AllowAutomaticUpdates="true" AllowSorting="false" AllowPaging="True"
                    OnNeedDataSource="gridBenefitVerification_NeedDataSource" Width="100%" DataKeyNames="EscalationCaseBvId" OnBatchEditCommand="gridBenefitVerification_BatchEditCommand">
                    <MasterTableView CommandItemDisplay="Top" EditMode="Batch">
                        <BatchEditingSettings EditType="Row" />
                        <CommandItemSettings ShowSaveChangesButton="false" ShowRefreshButton="false" ShowCancelChangesButton="false" />
                        <Columns>
                            <telerik:GridDateTimeColumn DataField="DateVerified" HeaderText="Date Benefit Verified*" UniqueName="DateVerified" HeaderStyle-Width="400" DataFormatString="{0:MM/dd/yyyy}">
                                <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                    <RequiredFieldValidator ForeColor="Red" Text="*This field is required" runat="server">
                                    </RequiredFieldValidator>
                                </ColumnValidationSettings>
                            </telerik:GridDateTimeColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>
            </div>
 
function saveChanges() {
                if (Page_IsValid) {
                    <%--var grid = $find("<%= gridPrescriptions.ClientID %>");
                    if (grid.get_masterTableView().get_dataItems().length > 0) {
                        grid.get_batchEditingManager().saveChanges(grid.get_masterTableView());
                    }
                    else {
                        var label = document.getElementById("<%= lblMessage.ClientID%>");
                        label.innerText = "Please add at least one prescription.";
                        label.style.color = "red";
                        label.style.display = "";
                        document.body.scrollTop = document.documentElement.scrollTop = 0;
                    }--%>
 
                    var gridRx = $find("<%= gridPrescriptions.ClientID %>");
                    var masterTableRx = gridRx.get_masterTableView();
 
                    if (masterTableRx.get_dataItems().length > 0) {
 
                        var gridBv = $find("<%= gridBenefitVerification.ClientID %>");
                        var masterTableBv = gridBv.get_masterTableView();
                        var batchEditManager = gridBv.get_batchEditingManager();
                        var tables = [];
 
                        //var changes1 = batchEditManager._changes;
                        //var changes2 = gridRx.get_batchEditingManager()._changes;
 
                        tables.push(masterTableRx);
                        tables.push(masterTableBv);
 
                        batchEditManager.saveTableChanges(tables);
                    }
                    else
                    {
                        var label = document.getElementById("<%= lblMessage.ClientID%>");
                        label.innerText = "Please add at least one prescription.";
                        label.style.color = "red";
                        label.style.display = "";
                        document.body.scrollTop = document.documentElement.scrollTop = 0;
                    }
                }
            }

 

 

Attila Antal
Telerik team
 answered on 22 Mar 2021
10 answers
915 views

Hi,

I am increasing the font size for RadRadioButtonList, but the radio circle remain small. see attached image.

Is there a way to increase the size of the radio button?

Regards,

Omar

Omar
Top achievements
Rank 3
Iron
Iron
Iron
 answered on 19 Mar 2021
1 answer
124 views

I have a RadGrid on my page that I use as a selector, and via it's SelectedIndexChanged I wanna set some header filter on another grid.

Each time the selection is changed in the first RadGrid (rgPendingRequests) I want to adjust the header filter of rgResponsables and filter the result. The user must then be able to change the header filter as he wish, in case the filter returns nothing.

This is the grid I wanna apply the header filter to

<telerik:RadGrid
    ID="rgResponsables"
    runat="server"
    Width="100%"
    Height="220px"
    AutoGenerateColumns="False"
    EnableViewState="true"
    AllowFilteringByColumn="True"
    AllowSorting="True"
    CssClass="gridPartageResponsables"
    EnableLinqExpressions="false"
>
    <GroupingSettings CaseSensitive="false"></GroupingSettings>
    <ClientSettings EnableRowHoverStyle="true" Selecting-AllowRowSelect="true" EnablePostBackOnRowClick="true" Scrolling-UseStaticHeaders="true" />
    <MasterTableView
        DataKeyNames="ResponsableID"  
        AllowFilteringByColumn="True"
    >
        <Columns>
            <telerik:GridBoundColumn DataField="Prenom" Visible="true" HeaderStyle-Font-Bold="true" HeaderText="Prénom" UniqueName="Prenom" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
            <telerik:GridBoundColumn DataField="Nom" Visible="true" HeaderStyle-Font-Bold="true" HeaderText="Nom" UniqueName="Nom" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
            <telerik:GridBoundColumn DataField="Courriel" Visible="true" HeaderStyle-Width="250px" HeaderStyle-Font-Bold="true" HeaderText="Courriel" UniqueName="Courriel" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
            <telerik:GridBoundColumn DataField="Telephone" Visible="true" HeaderStyle-Width="120px" HeaderStyle-Font-Bold="true" HeaderText="Téléphone" UniqueName="Telephone" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains" ShowFilterIcon="false" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Here is my code Behind:

Protected Sub rgPendingRequests_SelectedIndexChanged(sender As Object, e As EventArgs) _
Handles rgPendingRequests.SelectedIndexChanged
 
    Dim PrenomCol = rgResponsables.MasterTableView.GetColumnSafe("Prenom")
    PrenomCol.CurrentFilterFunction = GridKnownFunction.Contains
    PrenomCol.CurrentFilterValue = rgPendingRequests.SelectedValues("FirstName")
 
    Dim NomCol = rgResponsables.MasterTableView.GetColumnSafe("Nom")
    NomCol.CurrentFilterFunction = GridKnownFunction.Contains
    NomCol.CurrentFilterValue = rgPendingRequests.SelectedValues("LastName")
 
    rgResponsables.Rebind()
         
End Sub

But even though the values appear in the header filter, the table is not filtered until I go to a header filter field and press enter...

I've tried everything I can think of, and could not make it work...

I could really use some pointer on what I'm doing wrong...

Doncho
Telerik team
 answered on 19 Mar 2021
1 answer
112 views

Hello,

we have a grid with client databinding. Backend is a WCF web service.

The requirement is, the client side column filter setting(user has a filter text in the column Title) shall be restored if the page has been reloaded(for example after adding a new item).

But the Contains-filter doesn't work with part-match. It works only if the filter-text equals the Title(full match). It is the same with StartWith-filter.

What wasI wrong?

The Telerik.Web.UI assembly version is 2015.2.826.45

Please help. Thanks.

function applyFilter() {
    var grid = $find("<%= RadGrid_PublishedDocuments.ClientID %>");
    var tableView = grid.get_masterTableView();
 
    var column = tableView.getColumnByUniqueName("Title");
    column.set_filterFunction("Contains");
    tableView.filter("Title", "dcr", Telerik.Web.UI.GridFilterFunction.Contains, true);
    tableView.rebind();
}

 

 

Doncho
Telerik team
 answered on 19 Mar 2021
4 answers
323 views
I need an example when a user logs in. he/she will see their information.

I appreciate some examples.

Rumen
Telerik team
 answered on 18 Mar 2021
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?