Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
143 views
Hi, I would like to have a confirm button. Here what I have done so far:

Code-Behind:

protected void btnClear_Click(object sender, EventArgs e)

 

{

    RadWindowManager1.RadConfirm(

 

"ARE YOU SURE WANT TO CLEAR THE SEARCH FORM?", "buttonConfirm",450, 150, null, "INFO");

 

 

 

    if (hdfConfirm.Value == "true")

 

    {

        resetSearchForm();

    }

    

 

 

}


Javascript:

function

 

 

buttonConfirm(arg)
{
    if (arg)
    {
        //Set hidden field (hdfConfirm) value to true

 

        document.getElementById("<%=hdfConfirm.ClientID%>").value =

 

"true";

 

    }

 

 

    else 
    {
        //Set hidden field (hdfConfirm) value to false

 

        document.getElementById("<%=hdfConfirm.ClientID%>").value =

 

"false";

 

    }
    $find("<%=RadAjaxManager1.ClientID%>").ajaxRequest(arg);


 

But it didn't work. Would you please check to see if I'm missing something here?

 

Thanks

Lamk



LamKhoa
Top achievements
Rank 1
 answered on 08 Jul 2011
5 answers
307 views
I'm looking at your online demo for Exporting from the RadGrid.

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/exporting/defaultcs.aspx

I immediately click on the "Export to Excel" button.  While reviewing the exported Excel or Word file, I notice that each textbox in the grid's footer has replicated itself 3 times for Page where I believe it should only display once.  Please see attached screenshot (exportexcel.jpg).

I am experiencing something similar when exporting a RadGrid to Excel with a RadTextbox visible on a grid row.  Please see screenshot of grid before exporting (exportgrid.jpg).  Please see screenshot of exported data (exportedtextbox.jpg). I'm my example, the textbox & value are duplicated.

My grid column is defined like this:

<telerik:GridTemplateColumn UniqueName="colUnits" HeaderText="Units">
   <HeaderStyle Width="100px" HorizontalAlign="Left" />
   <ItemStyle Width="100px" HorizontalAlign="Right" />
   <ItemTemplate>
      <telerik:RadNumericTextBox ID="txtUnits" runat="server" Width="40px" AutoPostBack="false"
         NumberFormat-DecimalDigits="0" CausesValidation="false" MinValue="0" MaxLength="3"
         NumberFormat-AllowRounding="false" Style="text-align:right;">
          <ClientEvents OnValueChanged="txtUnits_OnValueChanged" />
          <ClientEvents OnKeyPress="KeyPress" />
      </telerik:RadNumericTextBox>
   </ItemTemplate>
</telerik:GridTemplateColumn>

The grid is NOT in edit mode and I would like to just export the data inside the textbox. 

When I attempt to do the following setting:

grid.ExportSettings.ExportOnlyData = True

The column with the textbox does not get any data exported at all to Excel or PDF.

If

grid.ExportSettings.ExportOnlyData = False

Then I get the issue described above with the replicated data when exporting to Excel.  Still no data get exported for PDF.

I believe this is either an export setting issue, a formatting issue, or a bug with the export functionality.

Please advise.
Daniel
Telerik team
 answered on 08 Jul 2011
1 answer
128 views
Is there any issues with the ability to filter using a filter template with a radcomb box in version 2009.2.826.35?
I can load the grid, create the radcombo and fill it with values but when I select a value from the combo xo nothin happens.

<telerik:RadGrid ID="RadGrid1" runat="server"  AllowPaging="True" EnableLinqExpressions ="false"
                    PageSize="25" AutoGenerateColumns="False" GridLines="None" AllowSorting="True" Width="100%"
                    AllowFilteringByColumn="true" AlternatingItemStyle-BackColor="#eeeeee" ShowStatusBar="True"
                    OnNeedDataSource="RadGrid1_NeedDataSource" OnItemDataBound="RadGrid1_ItemDataBound"
                    OnInsertCommand="RadGrid1_InsertCommand" OnUpdateCommand="RadGrid1_UpdateCommand" 
                    OnItemCreated="RadGrid1_ItemCreated">
                     <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" />
                            <MasterTableView CommandItemDisplay="Top" DataKeyNames="AuditID" EditMode="InPlace">
                                <AlternatingItemStyle BackColor="#EEEEEE"></AlternatingItemStyle>
                                <Columns>
                                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderStyle-Width="50px" />                                    
                                    <telerik:GridTemplateColumn HeaderText="Branch" SortExpression="" UniqueName="CRDBranchNumber"  HeaderStyle-Width="160px">                                  
                                       <ItemTemplate>
                                          <asp:Label runat="server" ID="lbCRDBranchNumber" Text='<%# Eval("CRDBranchNumber") %>' />
                                       </ItemTemplate>
                                       <EditItemTemplate>
                                          <telerik:RadComboBox ID="rcbCRDBranchNumber" DataTextField="CRDBranchNumber" DataValueField="CRDBranchNumber" runat="server" Width="115px" />
                                           <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="rcbCRDBranchNumber" ErrorMessage="*"
                                                 runat="server" ToolTip="Branch is Required" InitialValue="Select Branch"  ForeColor="Red" />
                                          <asp:Label runat="server" ID="ldID" Visible="false" Text='<%# Eval("CRDBranchNumber") %>' />
                                       </EditItemTemplate>
                                    </telerik:GridTemplateColumn>                                        
                                    <telerik:GridTemplateColumn HeaderText="Auditor" SortExpression="" UniqueName="Auditor"  HeaderStyle-Width="225px">
                                       <ItemTemplate>
                                          <asp:Label runat="server" ID="lbAuditor" Text='<%# Eval("AuditorName") %>' />
                                       </ItemTemplate>
                                       <EditItemTemplate>
                                          <telerik:RadComboBox ID="rcbAuditor" DataTextField="AuditorName" DataValueField="AuditorID" runat="server" Width="175px" />
                                           <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="rcbAuditor" ErrorMessage="*"
                                                 runat="server" ToolTip="Auditor is Required" InitialValue="Select Auditor"  ForeColor="Red" />
                                          <asp:Label runat="server" ID="ldAuditorID" Visible="false" Text='<%# Eval("AuditorID") %>' />
                                       </EditItemTemplate>
                                    </telerik:GridTemplateColumn>                                                                                                
                                    <telerik:GridNumericColumn DataField="AuditYear" HeaderText="Audit Year" SortExpression="AuditYear" UniqueName="AuditYear" 
                                          DataType="System.Decimal" DataFormatString="{0:F0}" />                     
                                    <telerik:GridDateTimeColumn  SortExpression="ScheduledDate" DataField="ScheduledDate"
                                        HeaderText="Scheduled" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                                        AllowFiltering="false" HeaderStyle-Width="100px" UniqueName="ScheduledDate" />
                                    <telerik:GridDateTimeColumn SortExpression="CompletedDate" DataField="CompletedDate"
                                        HeaderText="Completed" DataType="System.DateTime" DataFormatString="{0:MM/dd/yyyy}"
                                        AllowFiltering="false" HeaderStyle-Width="100px" UniqueName="CompletedDate" />                                        
                                    <telerik:GridTemplateColumn HeaderText="Status" SortExpression="" UniqueName="Status"  HeaderStyle-Width="195px">
                                       <FilterTemplate>
                                            <telerik:RadComboBox ID="rcbStatus" DataTextField="Status" DataValueField="Status"
                                                AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("Status").CurrentFilterValue %>'
                                                runat="server" AutoPostBack="true"  OnClientSelectedIndexChanged="TitleIndexChanged">
                                                    <Items>
                                                        <telerik:RadComboBoxItem Text="All" />
                                                    </Items>
                                                </telerik:RadComboBox>
                                                <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                                                    <script type="text/javascript">
                                                        function TitleIndexChanged(sender,args) {
                                                            var tableView=$find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                                            tableView.filter("Status",args.get_item().get_value(),"EqualTo");                                                            
                                                        }
                                                    </script>
                                                </telerik:RadScriptBlock>
                                       </FilterTemplate>
                                       <ItemTemplate>
                                          <asp:Label runat="server" ID="lblStatus" Text='<%# Eval("Status") %>' />
                                       </ItemTemplate>
                                       <EditItemTemplate>
                                          <telerik:RadComboBox ID="rcbStatus" DataTextField="Status" DataValueField="AuditStatusID" runat="server" Width="150px" />
                                          <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="rcbStatus" ErrorMessage="*"
                                                 runat="server" ToolTip="Status is Required" InitialValue="Select Status"  ForeColor="Red" />
                                          <asp:Label runat="server" ID="lbAuditStatusID" Visible="false" Text='<%# Eval("AuditStatusID") %>' />
                                       </EditItemTemplate>
                                    </telerik:GridTemplateColumn>                                                                                
                                </Columns>
                                <EditFormSettings>
                                    <EditColumn InsertText="Insert Audit" UpdateText="Update Audit" UniqueName="EditCommandColumn1"
                                        CancelText="Cancel edit">
                                    </EditColumn>
                                </EditFormSettings>
                            </MasterTableView>

I can get this to work in another application but I am using 2009.3.1314.35.
Eric Klein
Top achievements
Rank 1
 answered on 08 Jul 2011
2 answers
94 views
<radTree:RadTreeView ID="treeAddSection" CheckBoxes="true" runat="server" Width="700px"   Skin="HSTM" MultipleSelect="false" EnableEmbeddedSkins="false" RetainScrollPosition="true"   AutoPostBack="true">
<Nodes>
                <radTree:RadTreeNode Text="Node1" SelectedImageUrl="/image1.gif"></radTree:RadTreeNode>
                <radTree:RadTreeNode Text="Node2" SelectedImageUrl="/image1.gif"></radTree:RadTreeNode>
               <radTree:RadTreeNode Text="Node3" SelectedImageUrl="/image1.gif"></radTree:RadTreeNode>
</Nodes>
</radTree:RadTreeView>

The RadTree will populate with three nodes. Initially Select the "Node1" the selectedimageurl will displayed
for the node1. Now select the "Node3" the selectedImageUrl is showing for "Node3", without hiding the "Node1"
selected image url. I just want to only one at the same time.
vijayashankar palanichamy
Top achievements
Rank 1
 answered on 08 Jul 2011
2 answers
109 views
Hi,

I have a Toolbar located above a window manager. When the window manager is empty the Splitbutton menu is visible, but when the window manager loads a window the button menu goes behind the active window. I tried playing with the z-index but by default the toolbar has a higher index than the window.

I am using Telerik.Web.UI version 2011.1.519.35.

Yohancef
Top achievements
Rank 1
 answered on 08 Jul 2011
4 answers
210 views
Hi,

I have a Toolbar located above a window manager. When the window manager is empty the Splitbutton menu is visible, but when the window manager loads a window the button menu goes behind the active window. I tried playing with the z-index but by default the toolbar has a higher index than the window.

I am using Telerik.Web.UI version 2011.1.519.35.

<%

@ Page Language="C#" AutoEventWireup="true" CodeBehind="Main.aspx.cs" Inherits="Company.SecurePages.Main" Async="true" AsyncTimeout="30" %>

 

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

 

<!

 

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">

 

 

<link href="../Css/General.css" rel="stylesheet" type="text/css" />

 

</head>

 

<

 

body scroll="no" >

 

<

 

form id="form1" runat="server">

 

 

<

 

telerik:RadScriptManager ID="RadScriptManager1" runat="server">

 

</

 

telerik:RadScriptManager>

 

 

 

telerik:RadToolTip Title="Versions" runat="server" ID="HelpToolTip" ManualClose="true" Width="250px" ShowEvent="onclick"

 

TargetControlID

 

="HelpBtn" IsClientID="true" Position="BottomLeft"

 

>

</

 

telerik:RadToolTip>

 

<

 

telerik:RadToolTip Title="Session Timed Out" runat="server" ID="TimeoutToolTip" Width="250px"

 

ShowEvent

 

="onclick" TargetControlID="TimeoutLkBtn" IsClientID="true" HideEvent="FromCode"

 

Position

 

="TopCenter" Modal="true" OnClientBeforeHide="OnClientBeforeHide"

 

RelativeTo

 

="BrowserWindow" CssClass="rtCloseButton" >

 

 

<table width="100%">

 

 

<tr>

 

 

<td>

 

Your session is about to time out.

 

<br />

 

Do you want to continue this session?

 

</td>

 

 

</tr>

 

 

<tr>

 

 

<td align="center">

 

 

<asp:Button ID="YesBtn" Text="Yes" runat="server" Width="35px" OnClientClick="HideTimeoutMsg('Y'); return false;"/>

 

 

&nbsp;

 

 

<asp:Button ID="NoBtn" Text="No" runat="server" Width="35px" OnClientClick="HideTimeoutMsg('N'); return false;" />

 

 

</td>

 

 

</tr>

 

 

</table>

 

</

 

telerik:RadToolTip>

 

<

 

telerik:RadSplitter id="Radsplitter3" runat="server" height="99.5%" width="100%" Orientation="Horizontal">

 

 

<telerik:RadPane id="Radpane3" runat="server" Height="20px" Scrolling="None" CssClass="menuPanes" >

 

 

<div class="topBackground" style="height:20px; " >

 

 

<table width="100%" cellpadding="0" cellspacing="0" >

 

 

<tr>

 

 

<td style="width:10%">

 

 

<asp:LinkButton ID="TimeoutLkBtn" runat="server" CssClass="hiddenBtn"></asp:LinkButton>

 

 

<asp:LinkButton ID="PostBtn" runat="server" CssClass="hiddenBtn"></asp:LinkButton>

 

 

</td>

 

 

<td align="right" style="width:85%; ">

 

 

<telerik:RadMenu ID="UserRadMenu" runat="server" EnableEmbeddedSkins="false" style="float:right">

 

 

<Items>

 

 

<telerik:RadMenuItem runat="server" Text="" >

 

 

<Items>

 

 

<telerik:RadMenuItem runat="server" Text="Change Password" NavigateUrl="UserPassword.aspx" >

 

 

</telerik:RadMenuItem>

 

 

<telerik:RadMenuItem Text="Edit Authentication" NavigateUrl="EditMfa.aspx" >

 

 

</telerik:RadMenuItem>

 

 

</Items>

 

 

</telerik:RadMenuItem>

 

 

</Items>

 

 

</telerik:RadMenu>

 

 

</td>

 

 

<td style="width:5%">

 

 

<table width="100px" cellpadding="0" cellspacing="0" >

 

 

<tr>

 

 

<td style="width:10px; text-align:right;border-bottom-style:none; border-spacing:0px; border-right-width:0px; padding-left:0px; padding-right:0px; ">

 

 

<asp:Label ID="lbSeparator1" runat="server" ForeColor="Black" Text="|"></asp:Label>

 

 

</td>

 

 

<td align="center">

 

 

<asp:ImageButton ID="HelpBtn" runat="server" ImageUrl="~/Images/help_16X16.png"></asp:ImageButton>

 

 

</td>

 

 

<td style="width:10px; text-align:left; border-left-width:0px; border-right-width:0px; padding-left:0px; padding-right:0px; ">

 

 

<asp:Label ID="lbSeparator2" runat="server" ForeColor="Black" Text="|"></asp:Label>

 

 

</td>

 

 

<td style="width:50px">

 

 

<asp:LinkButton ID="LogoutLkBtn" OnClick="LogoutLkBtn_Click" runat="server" ForeColor="Black">Logout</asp:LinkButton>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</div>

 

 

</telerik:RadPane>

 

 

<telerik:RadPane id="Radpane4" runat="server" Height="85px" Scrolling="None" CssClass="ms-globalTitleArea">

 

 

<table width="100%" height="100%" cellpadding="0" cellspacing="0" style="border-bottom-width:0px; padding-bottom:0px;">

 

 

<tr valign="top" align="left">

 

 

<td colspan="2">

 

 

<img runat="server" id="BankImage" />

 

 

</td>

 

 

</tr>

 

 

<tr valign="bottom" align="left">

 

 

<td>

 

 

<telerik:RadToolBar Width="60px" ID="rtbAppMenu" runat="server" EnableEmbeddedSkins="true" OnClientButtonClicked="ClientItemClicked" OnButtonClick="rtbAppMenu_ButtonClick" >

 

 

<Items>

 

 

<telerik:RadToolBarSplitButton ImageUrl="../Images/view_detail.gif" ToolTip="Open Applications" EnableDefaultButton="false" Height="20px" HoveredCssClass="Hovered" >

 

 

<Buttons>

 

 

<telerik:RadToolBarButton runat="server" Text="App1" Value="App1" Visible="True" ></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="App2" Value="App2" Visible="True"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="App3" Value="App3" Visible="True"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="App4" Value="App4" Visible="True"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="IWA_App1" Value="IWA_App1" Visible="False"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="IWA_App2" Value="IWA_App2" Visible="False"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="IWA_App3" Value="IWA_App3" Visible="False"></telerik:RadToolBarButton>

 

 

<telerik:RadToolBarButton runat="server" Text="IWA_App4" Value="IWA_App4" Visible="False"></telerik:RadToolBarButton>

 

 

</Buttons>

 

 

</telerik:RadToolBarSplitButton>

 

 

</Items>

 

 

</telerik:RadToolBar>

 

 

</td>

 

 

<td style="width:100%; ">

 

 

<telerik:RadTabStrip runat="server" ID="RadTabStrip1" OnClientTabSelected="OnClientTabSelected" Width="100%" Skin="Vista" SelectedIndex="0" ScrollChildren="true" EnableEmbeddedSkins="true" Height="25px" >

 

 

<TabTemplate>

 

 

<asp:Label ID="TabTextLbl" runat="server" ></asp:Label>

 

 

<asp:ImageButton ID="CloseBtn" OnClientClick="CloseSelectedApplication(this)" ImageUrl="~/Images/Delete.gif" runat="server" ImageAlign="Middle" />

 

 

</TabTemplate>

 

 

</telerik:RadTabStrip>

 

 

</td>

 

 

</tr>

 

 

</table>

 

 

</telerik:RadPane>

 

 

<telerik:RadSplitBar id="Radsplitbar4" runat="server" CollapseMode="Forward"/>

 

 

<telerik:RadPane id="Radpane5" OnClientResized="PaneResized" Scrolling="None" Width="100%" Height="100%" runat="server">

 

 

</telerik:RadPane>

 

</

 

telerik:RadSplitter>

 

 

 

<telerik:RadWindowManager ShowContentDuringLoad="false" VisibleStatusbar="false" VisibleTitlebar="false" Behaviors="Maximize" ID="RadWindowManager" runat="server" RestrictionZoneID="Radpane5" DestroyOnClose="true" Skin="" EnableEmbeddedSkins="false" >

 

 

</telerik:RadWindowManager>

  

</

form>

 

</body>

 

</html>

 

Yohancef
Top achievements
Rank 1
 answered on 08 Jul 2011
1 answer
74 views
Hi;
Is the source code available for the four independent demos?
Telerik Sales Dashboard, Telerik Web Mail, Telerik Rent a Car and Telerik Event Scheduler

Thanks!
Ben Hayat
Top achievements
Rank 2
 answered on 08 Jul 2011
2 answers
213 views
I have a RadGrid using a custom skin that is inside of a row in a table with alternating row colors. The background color for the table row seems to be overriding the alternating row color for the RadGrid. i checked all the styles on my grid using Firebug and the .rgAltRow class is on my RadGrid row with the correct background color in the CSS. I have tried putting !important after the color and that changed nothing.

.RadGrid_MailMerlin .rgAltRow
{
    background: #ededed;
}

I have attached a screenshot of my grid. If you need any other code/css please let me know!

Thanks in advance.

Dan
Dan Miller
Top achievements
Rank 1
 answered on 08 Jul 2011
1 answer
273 views
Hi

I am attempting to add RadToolBarbuttons to a RadToolBar I have defined in my aspx file.

I am adding the elements successfully after creating them with the following server side code.

 

 


RadToolBarButton
rtb = new RadToolBarButton();

 

rtb.Group = sGroup;

rtb.CheckOnClick =

 

true;

 

rtb.Checked =

 

false;

 

rtb.PostBack =

 

true;

 

rtb.ImageUrl = sImageUrl;

rtb.Value = sValue;

rtb.ToolTip = sToolTip;

I add the rtb object, actually more than one, to my RadToolBar.

 


They all appear correctly in my UI.

However as soon as I mouse over them I get an exception.

I noticed the rendered html is different from an in-line RadToolBarButton.

The dynamically created buttons don't have _item["object Object"] or _itemTypeName["Telerik.Web.UI.RadToolBarButton"] attributes.

What am I missing?

TIA

 

Dimitar Terziev
Telerik team
 answered on 08 Jul 2011
4 answers
152 views
Good morning, I'm trying to change my old code to upload images. But it hascomplicated everything. I can not find how to adapt what I have to control radupload. Help me please.

Example
In this part of code

Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsString, ByVal strImgFolder As String)

        Dim strImageFolderPath As String

        Dim strImagePath As String

        Try

            '   Construct saving path

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)

            strImagePath = Path.Combine(strImageFolderPath, strPictureName)

            '   Upload image this part is not as fit

            FileUploader.PostedFile.SaveAs(strImagePath)

            FileUploader.PostedFile.InputStream.Dispose()

            FileUploader.Dispose()

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub



All code here

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) HandlesButton2.Click

        Dim tamano_fotoP As Integer

        Dim tamano_fotoG As Integer

        tamano_fotoP = 235

        tamano_fotoG = 649

        Try

            Dim strGuid As String = ""

            Dim strPicExtension As String = ""

            Dim strFileName As String = ""

            If PhotoUpload.HasFile = True Then

                strGuid = fnGuid()

                strPicExtension = fnGetPictureExtension(PhotoUpload.FileName)

                strFileName = strGuid & strPicExtension

                txtfoto.Text = strFileName

                If strPicExtension <> "none" Then

                    subAddNewPicture(PhotoUpload, strFileName, "Imagenes")

                    Resize_Image(tamano_fotoP, tamano_fotoP, strFileName, "~/Imagenes/","P/")

                    Resize_Image(tamano_fotoG, tamano_fotoG, strFileName, "~/Imagenes/","G/")

                    sqldata.Insert()

                    PhotoUpload.PostedFile.InputStream.Dispose()

                    PhotoUpload.Dispose()

                    GC.Collect()

                    eliminar_foto(strFileName, "")

                Else

                    lblmensaje.Text = "Por favor seleccione una imagen..."

                End If

            Else

                lblmensaje.Text = "Por favor seleccione una imagen..."

            End If

            lblmensaje.Visible = True

        Catch ex As Exception

        End Try

    End Sub

    Protected Sub eliminar_temporales()

        Dim file() As FileInfo

        Dim i As Integer

        Dim txtpath As String

        txtpath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes")

        If txtpath <> "" Then

            Dim dir As New DirectoryInfo(txtpath)

            file = dir.GetFiles()

            If file.Length > 0 Then

                For i = 0 To file.Length - 1

                    Try

                        file(i).Delete()

                    Catch ex As Exception

                        'Throw ex

                    End Try

                Next

            End If

        End If

    End Sub

    Public Sub eliminar_foto(ByVal nombre_foto As String, ByVal folder As String)

        Dim strImagePath, strImageFolderPath As String

        Try

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, "Imagenes"& folder)

            strImagePath = Path.Combine(strImageFolderPath, nombre_foto)

            System.IO.File.Delete(strImagePath)

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub

    Public Sub Resize_Image(ByVal intMaxWidth As Short, ByVal intMaxHeigth As Short, ByValfoto As String, ByVal folder As String, ByVal atributo As String)

        Dim img As Image

        img = System.Drawing.Image.FromFile(MapPath(folder & foto))

        Dim oImg As Bitmap = New System.Drawing.Bitmap(img)

        'Assign image dimensions

        Dim oldWidth As Integer

        Dim oldHeight As Integer

        Dim newWidth As Integer

        Dim newHeight As Integer

        Dim ratio As Decimal

        oldWidth = oImg.Width

        oldHeight = oImg.Height

        ratio = oldWidth / oldHeight

        newWidth = intMaxWidth

        newHeight = newWidth / ratio

        'rutina para ver si la foto es mas pequena del tamano a recortar dejandola igual

        If oImg.Width < intMaxWidth Then

            newWidth = oImg.Width

            newHeight = oImg.Height

        End If

        Dim OutputBitmap As Bitmap = New Bitmap(oImg, CInt(newWidth), CInt(newHeight))

        Dim encoderParams As System.Drawing.Imaging.EncoderParameters = NewSystem.Drawing.Imaging.EncoderParameters()

        Dim quality As Long

        Dim imageFormat = img.RawFormat

        Dim myresizer As Graphics

        myresizer = Graphics.FromImage(OutputBitmap)

        'myresizer.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality

        'myresizer.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality

        myresizer.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic

        myresizer.DrawImage(img, 0, 0, newWidth, newHeight)

        'Compress image

        Dim comp As Integer

        If atributo = "G/" Then

            comp = 60

        Else

            comp = 70

        End If

        quality = comp ' 0 to 100 - 100 highest quality

        Dim encoderParam As System.Drawing.Imaging.EncoderParameter = NewSystem.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Quality, quality)

        encoderParams.Param(0) = encoderParam

        Dim arrayICI As ImageCodecInfo() = ImageCodecInfo.GetImageEncoders()

        Dim jpegICI As ImageCodecInfo

        Dim x As Integer

        For x = 0 To arrayICI.Length - 1

            If (arrayICI(x).FormatDescription.Equals("JPEG")) Then

                jpegICI = arrayICI(x)

                Exit For

            End If

        Next

        'Save original image

        If Not jpegICI Is Nothing Then

            OutputBitmap.Save(Server.MapPath(folder) & atributo & foto, jpegICI, encoderParams)

        End If

        '  clean up

        OutputBitmap.Dispose()

    End Sub

#Region "Public Functions"

    '   Adds picture to specified folder

   

Public Sub subAddNewPicture(ByVal FileUploader As FileUpload, ByVal strPictureName AsString, ByVal strImgFolder As String)

        Dim strImageFolderPath As String

        Dim strImagePath As String

        Try

            '   Construct saving path

            strImageFolderPath = Path.Combine(Request.PhysicalApplicationPath, strImgFolder)

            strImagePath = Path.Combine(strImageFolderPath, strPictureName)

            '   Upload image ACTUALIZADO

            FileUploader.PostedFile.SaveAs(strImagePath)

            FileUploader.PostedFile.InputStream.Dispose()

            FileUploader.Dispose()

        Catch ex As Exception

            'Throw ex

        End Try

    End Sub

    '   Function to generate a GUID using current date and time

    Public Function fnGuid() As String

        Dim strGuid As String = ""

        Try

            With Today

                strGuid = .Year & .Month & .Day & Now.Hour & Now.Minute & Now.Second

            End With

        Catch ex As Exception

            Throw ex

        End Try

        '   returning the guid generated

        Return strGuid

    End Function

    '   Returns true if file name has the extension .jpg, .gif, .jpeg

    Public Function fnGetPictureExtension(ByVal strPictureName As String) As String

        Try

            With strPictureName.ToUpper

                If .EndsWith(".JPG") Then

                    Return ".JPG"

                ElseIf .EndsWith(".GIF") Then

                    Return ".GIF"

                ElseIf .EndsWith(".JPEG") Then

                    Return ".JPEG"

                ElseIf .EndsWith(".PNG") Then

                    Return ".PNG"

                ElseIf .EndsWith(".BMP") Then

                    Return ".BMP"

                End If

            End With

        Catch ex As Exception

            Throw ex

        End Try

        ' Else if has no extension so it returns ""

        Return "none"

    End Function

#End Region


Dimitar Terziev
Telerik team
 answered on 08 Jul 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Shiori
Top achievements
Rank 2
Iron
Tien
Top achievements
Rank 1
Iron
Robert
Top achievements
Rank 1
Rob
Top achievements
Rank 4
Bronze
Bronze
Iron
Geoff
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?