Jul 26, 2010, 9:50 AM
FileUploadField help
Hi
I have the following code which uses a FileUploadField field, how do I access the file to upload it to my server? Can I do this in my code behind file? If the control saves the file without my needing to use a code behind file how do I know where the file will be saved and can I set it's path?
I have the following code which uses a FileUploadField field, how do I access the file to upload it to my server? Can I do this in my code behind file? If the control saves the file without my needing to use a code behind file how do I know where the file will be saved and can I set it's path?
<%@ Control Language="VB" AutoEventWireup="true" CodeFile="pulsebar.ascx.vb" Inherits="pages_cms_controls_pulseBar" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<asp:SqlDataSource ID="pulseDataSource"
Runat="server"
EnableCaching="false"
ConnectionString="<%$ ConnectionStrings:HomePage %>"
SelectCommand="SELECT * FROM Pulse WHERE deleted=0 ORDER BY publishon DESC"
InsertCommand="INSERT INTO Pulse (URL, Image, Title, publishon, modified, deleted, published) VALUES (@URL, @Image, @Title, @publishon, GetDate(), 0, 0)"
DeleteCommand="UPDATE Pulse SET deleted=1, modified=GetDate() WHERE PulseID=@PulseID"
UpdateCommand="UPDATE Pulse SET publishon=@publishon, published=@published, modified=GetDate(), URL=@URL, Image=@Image, Title=@Title WHERE PulseID=@PulseID"
>
<InsertParameters>
<asp:Parameter Name="URL" />
<asp:Parameter Name="Image" />
<asp:Parameter Name="Title" />
</InsertParameters>
<DeleteParameters>
<asp:Parameter Name="PulseID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="PulseID" />
<asp:Parameter Name="Title" />
<asp:Parameter Name="URL" />
<asp:Parameter Name="Image" />
<asp:Parameter Name="published" Type="Boolean" />
</UpdateParameters>
</asp:SqlDataSource>
<ext:Store ID="pulseStore" runat="server" DataSourceID="pulseDataSource">
<Reader>
<ext:JsonReader ReaderID="PulseID">
<Fields>
<ext:RecordField Name="URL" />
<ext:RecordField Name="Title" />
<ext:RecordField Name="Image" />
<ext:RecordField Name="published" Type="Boolean" />
<ext:RecordField Name="publishon" Type="Date" />
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<asp:Literal runat="server" ID="debug" />
<ext:GridPanel ID="pulseGridPanel" runat="server" StoreID="pulseStore" Width="985" Height="470" BodyBorder="false" >
<TopBar>
<ext:Toolbar ID="Toolbar2" runat="server">
<Items>
<ext:Button ID="Button4" runat="server" Text="Add" Icon="Add">
<Listeners>
<Click Handler="#{pulseGridPanel}.insertRecord();" />
</Listeners>
</ext:Button>
<ext:Button ID="Button5" runat="server" Text="Save" Icon="DatabaseSave">
<Listeners>
<Click Handler="#{pulseGridPanel}.save();" />
</Listeners>
</ext:Button>
<ext:Button ID="Button1" runat="server" Text="Reload" Icon="Reload">
<Listeners>
<Click Handler="#{pulseGridPanel}.reload();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel>
<Columns>
<ext:CommandColumn Width="30">
<Commands>
<ext:GridCommand Icon="Delete" CommandName="Remove">
<ToolTip Text="Remove" />
</ext:GridCommand>
</Commands>
</ext:CommandColumn>
<ext:Column Header="Title" DataIndex="Title" Width="250">
<Editor>
<ext:TextField ID="TextField1" runat="server"></ext:TextField>
</Editor>
</ext:Column>
<ext:Column Header="Image" DataIndex="Image" Width="150">
<Editor>
<ext:FileUploadField ID="ImageUpload" DataIndex="Image" ButtonText="Browse" runat="server" ButtonOnly="true" />
</Editor>
</ext:Column>
<ext:Column Header="URL" DataIndex="URL" Width="350">
<Editor>
<ext:TextField ID="TextField5" runat="server"></ext:TextField>
</Editor>
</ext:Column>
<ext:CheckColumn ColumnID="published" Header="Published" Align="Center" DataIndex="published" Width="90" Editable="true" />
<ext:Column Header="Publish On" DataIndex="publishon">
<Renderer Fn="Ext.util.Format.dateRenderer('d-M-Y')" />
<Editor>
<ext:DateField ID="DateField1" runat="server" Format="dd-MMM-Y"></ext:DateField>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel2" runat="server" SingleSelect="true">
</ext:RowSelectionModel>
</SelectionModel>
<Listeners>
<Command Handler="#{pulseGridPanel}_handleDelete();" />
</Listeners>
<LoadMask ShowMask="true" />
</ext:GridPanel>
<script type="text/javascript">
function <%= pulseGridPanel.ClientID %>_handleDelete () {
Ext.Msg.show({
title:'Delete?',
msg: 'Are you sure you want to delete?',
buttons: Ext.Msg.YESNO,
fn: <%= pulseGridPanel.ClientID %>_processDelete,
icon: Ext.MessageBox.QUESTION
});
}
function <%= pulseGridPanel.ClientID %>_processDelete (response) {
if (response == 'yes') {
<%= pulseGridPanel.ClientID %>.deleteSelected();
<%= pulseGridPanel.ClientID %>.save();
}
}
</script>
Last edited by geoffrey.mcgill; Jul 26, 2010 at 4:30 PM.
Reason: please use [code] tags