This is a migrated thread and some comments may be shown as answers.

file upload control is not working in my rad window

2 Answers 153 Views
Window
This is a migrated thread and some comments may be shown as answers.
Prassin
Top achievements
Rank 1
Prassin asked on 05 Jul 2012, 12:17 PM
Hi all,,

i have a rad window and its contain a file upload... when i try to catch file path instead of a button click the file upload control should be always null.... and its shown an error...

please help..


Regards,

Prassin 

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 05 Jul 2012, 12:33 PM
Hello,

Here is the sample code that I tried which worked as expected.
aspx:
<telerik:RadWindow ID="RadWindow1" runat="server" VisibleOnPageLoad="true">
  <ContentTemplate>
    <telerik:RadUpload ID="RadUpload1" runat="server"></telerik:RadUpload>
    <asp:Button ID="btn" runat="server"  OnClientClick="OnClientClick();return false;"/>
  </ContentTemplate>
</telerik:RadWindow>
JS:
function OnClientClick() {
 var upload = $find("<%= RadUpload1.ClientID %>");
}

Thanks,
Shinu.
0
Prassin
Top achievements
Rank 1
answered on 06 Jul 2012, 05:33 AM
Hi Shinu,

Please see the code and source 

Code Behind

Protected Sub btnUpload_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnUpload.Click
        Try
            Dim a As String = RadButton1.Text
            Dim extension As String = Path.GetExtension(imgUpload.FileName)
            If (extension.ToUpper = ".JPG") Or (extension.ToUpper = ".GIF") Or (extension.ToUpper = ".BMP") Or (extension.ToUpper = ".PNG") Then
                imgLogo.Visible = True
                Dim CurrentFileName As String
                CurrentFileName = imgUpload.FileName
                Dim CurrentPath As String = Server.MapPath("~/Presentation Layer/Upload/")
                If imgUpload.HasFile Then
                    CurrentPath += CurrentFileName
                    imgUpload.SaveAs(CurrentPath)
                Else
                    RadAjaxManager1.Alert("Please select an image file")
                    Exit Sub
                End If
                Dim strImagePath As String = imgUpload.FileName
                imgLogo.ImageUrl = ("~/Presentation Layer/Upload/" & strImagePath & "")
 
                Static Dim imgByte As Byte() = Nothing
                imgByte = File.ReadAllBytes(Server.MapPath(imgLogo.ImageUrl))
                Session("imageByte") = imgByte
            Else
                imgLogo.Visible = False
                RadAjaxManager1.Alert("Please select an image")
            End If
 
            'End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

Source

<telerik:RadWindow runat="server" ID="RadWindow_ContentTemplate" RestrictionZoneID="ContentTemplateZone"
           Modal="true" Skin="Office2010Blue" Height="312px" Width="478px">
           <ContentTemplate>
               <p class="contText">
                   Hi, Pleae upload photo here and click complete button..
               </p>
               <div class="contButton">
                   Upload photo :
                   <asp:FileUpload ID="imgUpload" runat="server" ToolTip="File Size limit 500KB, (jpg, bmp, png, gif)"
                       Width="178px"></asp:FileUpload></div>
               <div class="contButton">
                         <asp:Button ID="btnUpload" runat="server" Font-Size="8pt"
                       Text="Upload photo" onclick="btnUpload_Click" /></div>
               <div class="contButton">
                   <asp:Image ID="imgLogo" runat="server" Visible="true" AutoAdjustImageControlSize="false"
                       Height="150px" Width="100px"></asp:Image></div>
               <div class="contButton">
                   <telerik:RadButton ID="RadButtonUpload" runat="server" Text="Upload" Width="200px">
                       <Icon SecondaryIconCssClass="rbOpen" SecondaryIconRight="4" SecondaryIconTop="4" />
                   </telerik:RadButton>
               </div>
               <div class="contButton">
                   <telerik:RadTextBox ID="RadButton1" runat="server" Text="Upload" Width="200px">
                   </telerik:RadTextBox>
               </div>
           </ContentTemplate>
       </telerik:RadWindow>


in my scenario i need to fill my imagebox when i click Upload photo button inside the rad window... when i try to catch the file from file upload that time its show a null value.. please help

Regards

Prassin
Tags
Window
Asked by
Prassin
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Prassin
Top achievements
Rank 1
Share this question
or