PDA

View Full Version : [CLOSED] MultiUpload sending parameters



debarry
Jun 24, 2014, 5:43 PM
Hi,

Im using Multiupload so I can upload multiple files at once.
The files are received and processed by an .ashx file.
It works fine!

How can send more parameters to this .ashx page from the inicial page?

geoffrey.mcgill
Jun 24, 2014, 5:50 PM
Maybe adding your values to the <PostParams> can help.

debarry
Jun 24, 2014, 6:15 PM
Can I see some examples?
Thank you.

geoffrey.mcgill
Jun 24, 2014, 7:01 PM
Sure. Can you provide a simplified sample demonstrating what you have tested so far with PostParams. That will help get us started.

debarry
Jun 24, 2014, 7:36 PM
Thats what i have so far:


<ext:MultiUpload
ID="MultiUpload1"
runat="server"
OnFileUpload="MultiUpload1_FileUpload"
FileDropAnywhere="True"
FileSizeLimit="500 MB"
FileTypes="*.*"
FileTypesDescription="All Files"
FileUploadLimit="500"
FileQueueLimit="0"
UploadUrl="~/UploadDocumento.ashx"
AutoScroll="False">
<PostParams>
<ext:Parameter Name="IdClass" Value="ContentPlaceHolder1_DDIdClass.value" Mode="Raw" Encode="true" />
</PostParams>
<Listeners>
<SwfUploadLoadFailed Fn="loadFailed" />
<FileQueued Fn="BeginUpload" />
<FileSelected Fn="fileSelected" />
<UploadStart Handler="updateRecord(file.id, 'status', 'Sending');" />
<UploadProgress Handler="updateRecord(file.id, 'progress', Math.round(bytesComplete / bytesTotal));" />
<UploadComplete Handler="updateRecord(file.id, 'progress', 1 );updateRecord(file.id, 'status', 'Uploaded' );" />
<UploadAborted Handler="updateRecord(file.id, 'status', 'Aborted');" />
<UploadRemoved Handler="var store = this.up('grid').store; store.remove(store.getById(file.id));" />
<UploadError Fn="uploadError" />
<FileSelectionError Fn="fileSelectionError" />
</Listeners>
<Button>
<ext:Button Text="Pesquisar..." />
</Button>
</ext:MultiUpload>

Should "ContentPlaceHolder1_DDIdClass.value" be replaced by something else?
Its here:


<ext:SelectBox ID="DDIdClass" runat="server" DisplayField="ClassTitulo" ValueField="IdClass" FieldLabel="Classifica??o" OnDirectSelect="DDIdClass_OnDirectSelect" AutoPostBack="False" CausesValidation="True">
<Store>
<ext:Store ID="Store3" runat="server" DataSourceID="SqlDataSourceClassList">
<Model>
<ext:Model ID="ModelClass" runat="server">
<Fields>
<ext:ModelField Name="IdClass" />
<ext:ModelField Name="ClassTitulo" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
</ext:SelectBox>

The page UploadDocumento.ashx uses this code to lood for the IdClass parameter:


IdClass = Convert.ToInt32(context.Request["IdClass"]);

Thanks again!

debarry
Jun 24, 2014, 8:19 PM
It worked!
I've used this:


<PostParams>
<ext:Parameter Name="IdClass" Value="Ext.encode(#{DDIdClass}.value)" Mode="Raw" Encode="false"/>
</PostParams>

Also, the encode=false removes extra caracters when receiving the data and makes my work simpler.

:D

Thank you!

VilcheS
Aug 31, 2015, 7:26 AM
Hi all !

Well, I´m trying to do the same but in MVC 3.2.1, I don´t know how to read the
.PostParams()

My code looks like this:

X.MultiUpload()
.ID("LayoutsResourceInputResourcesAdd")
.FileSizeLimit("10 MB")
.Namespace("Resources")
.AutoStartUpload(true)
.FileUploadLimit(10)
.FileQueueLimit(0)
.FileTypes("*.*")
.UploadUrl(Url.Action("CreateResource"))
.PostParams(x => {
new Parameter("ResourceID", "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceID", ParameterMode.Raw);
new Parameter("ResourceName", "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceName", ParameterMode.Raw);
new Parameter("ResourceSize", "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceSize", ParameterMode.Raw);
new Parameter("ResourceDate", "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceDate", ParameterMode.Raw);
new Parameter("ResourceType", "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceType", ParameterMode.Raw);
})
)

And:

public DirectResult CreateResource( FileUploadEventArgs a)
{
...
}
I have seen other posts using
context.Request["IdClass"] or
Read it directly from Request collection, but I guess it's only for WebForms, not MVC.
What should I add in that code to read that kind of parameters?

Thanks in advance

Daniil
Aug 31, 2015, 9:19 AM
Hello @VilcheS,

In MVC please use HttpContext.Request.Params["parameter name"].

View

@{
var X = Html.X();
}

<!DOCTYPE html>
<html>
<head>
<title>Ext.Net.MVC v3 Example</title>
</head>
<body>
@X.ResourceManager()

@(X.MultiUpload()
.ID("MultiUpload1")
.UploadUrl(Url.Action("Upload"))
.PostParams(p => p.Add(new { testParameter = "test parameter value" }))
)

@X.Button().Text("Upload").Handler("App.MultiUpload1.startUpload();")
</body>
</html>


Controller

public ActionResult Upload(FileUploadEventArgs a)
{
X.Msg.Alert("PostParams", HttpContext.Request.Params["testParameter"]).Show();

return this.Direct();
}

VilcheS
Aug 31, 2015, 10:15 AM
Works!

I had to do little changes in my code:

.PostParams(p => {
p.Add(new Parameter ( "ResourceID" , "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceID", ParameterMode.Raw ));
p.Add(new Parameter ( "ResourceName" , "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceName", ParameterMode.Raw ));
p.Add(new Parameter ( "ResourceSize" , "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceSize", ParameterMode.Raw ));
p.Add(new Parameter ( "ResourceDate" , "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceDate", ParameterMode.Raw ));
p.Add(new Parameter ( "ResourceType" , "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceType", ParameterMode.Raw ));
})

because I wanted a value from the client like "10090", and not "App.LayoutsResourcesTreeGridResources.selection.da ta.resourceID", but it works :)

Thx again Daniil