Unable to bind the browsed images in Blazor file upload - c#

I am learning blazor and c# fundas with a simple app.mud blazor i am using for UI style but here I am unable to bind browsed images in to mudcards( ).The main idea of this app will allow you to browse all kind of files including images.As all kind files we can browse, i need a seperate class for images only so when ever user select file, first class-BrowserFileWithStatus list will trigger the second class-MediaVariantUI (lists)
class 1-BrowserFileWithStatus - list of this class NOT use to bind to the UI
class 2-MediaVariantUI- list of this class will use to bind to the UI
How can i bind browsed images in to MudCardMedia
//FIRST CLASS
public class BrowserFileWithStatus: FileWithStatusBase
{
public BrowserFileWithStatus(IBrowserFile file)
{
File = file ?? throw new ArgumentNullException(nameof(file));
FileName = Path.GetFileName(File.Name);
}
public IBrowserFile File { get; }
}
public class FileWithStatusBase: IFileWithStatus
{
private readonly string fileName = null!;
public string FileNameWithoutExtension { get; private init; } = null!;
public string FileExtension { get; private init; } = null!;
public string FileName
{
get => fileName;
protected init
{
fileName = value;
FileExtension = Path.GetExtension(fileName.AsSpan())[1..].ToString();
FileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileName);
}
}
}
public interface IFileWithStatus
{
string FileNameWithoutExtension { get; }
string FileExtension { get; }
string FileName { get; }
}
//SECOND CLASS-USING FOR IMAGE ONLY OPERATIONS
public class MediaVariantUI
{
private BrowserFileWithStatus file;
public MediaVariantUI(BrowserFileWithStatus file)
{
File = file;
this.file = file;
Name = file.FileName;
ContentType = file.File.ContentType;
FileNameWithoutExtension = file.FileNameWithoutExtension;
}
public BrowserFileWithStatus File { get; }
public String Name { get; set; }
public String FileNameWithoutExtension { get; set; }
public String ContentType { get; set; }
}
//MAIN UI PAGE
#page "/MediaUpload"
#using FileUpload.Models;
<EditForm Model="mediaformmodels" OnValidSubmit="CreateMediaNewFormAsync">
<FileuploadComponent #bind-SelectedFiles="mediaformmodels.ListFileToUpload"> </FileuploadComponent>
#if (mediaformmodels.ListMediaVariantUI != null && mediaformmodels.ListMediaVariantUI.Count > 0)
{
<MudcardComponent MediaVariantUIList="mediaformmodels.ListMediaVariantUI"> </MudcardComponent>
}
<MudGrid Class="mt-4 pt-1" Justify="Justify.FlexEnd">
<MudItem>
<MudButton Size="Size.Large"
Variant="Variant.Filled"
Color="Color.Primary"
StartIcon="#Icons.Material.Outlined.Save"
ButtonType="ButtonType.Submit">
SUBMIT
</MudButton>
</MudItem>
</MudGrid>
</EditForm>
#code {
private MediaFormModels mediaformmodels = new();
private async Task CreateMediaNewFormAsync()
{
foreach (var mediaFile in mediaformmodels.ListMediaVariantUI.Where(x => x != null))
{
//save each media files
}
}
}
//MediaFormModels class for mediaformmodels
using System.ComponentModel.DataAnnotations;
namespace FileUpload.Models
{
public class MediaFormModels
{
private List<MediaVariantUI>? listMediaVariantUIValue = new();
private List<BrowserFileWithStatus>? listFileToUpload = new();
public IReadOnlyList<BrowserFileWithStatus>? ListFileToUpload
{
get
{
return listFileToUpload;
}
set
{
listFileToUpload = value.ToList();
ListMediaVariantUI = value.Select(file => new MediaVariantUI(file)).ToList();
}
}
public IReadOnlyList<MediaVariantUI>? ListMediaVariantUI
{
get { return listMediaVariantUIValue; }
set { listMediaVariantUIValue = value.ToList(); }
}
}
}
//FILE UPLOAD PAGE
#using FileUpload.Models;
<h3>FileuploadComponent</h3>
<InputFile id="fileInput" OnChange="OnFilesChanged" hidden multiple />
<MudButton HtmlTag="label"
Variant="Variant.Filled"
Color="Color.Success"
StartIcon="#Icons.Filled.CloudUpload"
for="fileInput">
Upload Image
</MudButton>
#code {
[Parameter]
public IReadOnlyList<BrowserFileWithStatus> SelectedFiles { get; set; } = Array.Empty<BrowserFileWithStatus>();
[Parameter]
public EventCallback<IReadOnlyList<BrowserFileWithStatus>> SelectedFilesChanged { get; set; }
private async Task OnFilesChanged(InputFileChangeEventArgs eventArgs)
{
//i know following code is used to get image data but how can i asign to second class list when first class list triggered
//foreach (var imageFile in e.GetMultipleFiles(maxAllowedFiles))
//{
// var resizedImageFile = await imageFile.RequestImageFileAsync(format, 100, 100);
// var buffer = new byte[resizedImageFile.Size];
// await resizedImageFile.OpenReadStream().ReadAsync(buffer);
// var imageDataUrl = $"data:{format};base64,{Convert.ToBase64String(buffer)}";
//}
//For image binding i have a card component-I need to get image here from second list which is coming from fileupload component
_ = eventArgs ?? throw new ArgumentNullException(nameof(eventArgs));
var files = new List<BrowserFileWithStatus>(eventArgs.FileCount);
files.AddRange(eventArgs.GetMultipleFiles(10000).Select(file => new BrowserFileWithStatus(file)));
SelectedFiles = files;
await SelectedFilesChanged.InvokeAsync(SelectedFiles).ConfigureAwait(false);
}
}
//how i can bind image in below code <MudCardMedia Image="" Height="200" />
//For image binding i have a card component-I need to get image here from second list which is coming from fileupload component
#using FileUpload.Models;
<h3>Display selected Images</h3>
<MudPaper Width="100%" Class="darkbackground" MinHeight="350">
<MudContainer>
<MudGrid Spacing="#spacing" Justify="Justify.Center">
#foreach (var item in MediaVariantUIList)
{
<MudItem xs="4" Style="display:flex;">
<MudCard Height="350px" Width="300px">
<MudCardMedia Image="" Height="200" />
<MudCardContent>
<input #bind="#item.FileNameWithoutExtension" #bind:event="oninput" />
#* <MudTextField #bind-Value="#item.FileNameWithoutExtension" #bind:event="oninput" Label="Name" Variant="Variant.Text" Margin="Margin.Dense"></MudTextField>*#
<MudText Class="textsilver" Typo="Typo.body2">#item.Name</MudText>
</MudCardContent>
<MudCardActions>
<MudIconButton Icon="#Icons.Material.Filled.Delete" Variant="Variant.Outlined" Color="Color.Error" Size="Size.Small" />
</MudCardActions>
</MudCard>
</MudItem>
}
</MudGrid>
</MudContainer>
</MudPaper>
#code {
public int spacing { get; set; } = 2;
[Parameter]
public IReadOnlyList<MediaVariantUI> MediaVariantUIList { get; set; } = Array.Empty<MediaVariantUI>();
}

Related

Pass Type from parent component to a child user control in Blazor

I'm creating a user control to import csv file 'using CsvHelper;',
Parent Component
<ImportCsv Id="importCsv" sizeAllowedInKB=#fileSize typeAllowed=#fileTypeAllowed csvRows=#csvRowsType name="Import csv" />
#code{
private Type csvRowsType = typeof(CsvRows);
// CsvRows will always be different as this component can be user across project
}
Child component
<InputFile id="#Id" OnChange="#LoadFiles" accept="#typeAllowed" class="button button-small" />
<span title="add" class="icon-plus"></span>#name
#code{
[Parameter] public string typeAllowed { get; set; }
[Parameter] public int sizeAllowedInKB { get; set; }
[Parameter] public Type csvRows { get; set; }
[Parameter] public string name { get; set; }
[Parameter] public string Id { get; set; }
private async Task LoadFiles(InputFileChangeEventArgs e)
{
try
{
using (Stream ms = new MemoryStream())
{
await e.File.OpenReadStream().CopyToAsync(ms);
ms.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(ms))
{
Console.WriteLine($"StreamReader {reader.ReadToEnd()}");
CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture);
var csvReords = csv.GetRecords(Type.GetType(csvRows.FullName));
Console.WriteLine($"type of csvRows {csvRows} record count {csvReords.Count()} fullName {Type.GetType(csvRows.FullName)} ddd {csvRows.GetType()}");
Console.WriteLine($"Serialize {System.Text.Json.JsonSerializer.Serialize(csvReords)}");
};
}
}
catch (Exception ex)
{
Console.WriteLine("File: {Filename} Error: {Error}", e.File.Name, ex.Message);
}
}
}
}
Issue hear is I can see csv data on console
Console.WriteLine($"StreamReader {reader.ReadToEnd()}");
I can see type I'm passing from Parent
Console.WriteLine($"type of csvRows {csvRows} record count {csvReords.Count()} fullName {Type.GetType(csvRows.FullName)} ddd {csvRows.GetType()}");
but somehow
var csvReords = csv.GetRecords(Type.GetType(csvRows.FullName));
not returning anything, count is zero
Fixed this issue, commenting solution in case someone still looking for the same
Parent
<ImportCsv TValue=CsvRows Id="importCsv" sizeAllowedInKB=5 typeAllowed=".csv" name="Import Csv" csvData="ConsumeData" />
#Code
{
private void ConsumeData(List<CsvRows> csvData)
{
// Consume csv Data
}
}
Child
public partial class ImportCsv<TValue> : ComponentBase
{
[Parameter] public int sizeAllowedInKB { get; set; }
[Parameter] public string typeAllowed { get; set; } = ".csv";
[Parameter] public string name { get; set; } = "Import csv";
[Parameter] public string Id { get; set; } = "ImportCsv";
[Parameter] public EventCallback<List<TValue>> csvData { get; set; }
private async Task LoadFiles(InputFileChangeEventArgs e)
{
try
{
using (Stream ms = new MemoryStream())
{
await e.File.OpenReadStream().CopyToAsync(ms);
ms.Seek(0, SeekOrigin.Begin);
using (StreamReader reader = new StreamReader(ms))
{
CsvReader csv = new CsvReader(reader, CultureInfo.InvariantCulture);
var csvReords = csv.GetRecords<TValue>().ToList();
csvData.InvokeAsync(csvReords);
};
}
}
catch (Exception ex)
{
Console.WriteLine("File: {Filename} Error: {Error}", e.File.Name, ex.Message);
}
}

binding mudblazor treeview to an object

I am new to blazor and need to create a dynamic treeview where nodes can be created and deleted. All this data is saved in database. After pulling the data from database what kind of object I need to create to bind to Mudtreeview?
If only first level nodes are rendered initially, how can I load the children on node click?
is there any example somewhere? All the sample code on mudblazor site is with static data.
Adding and removeing items is easy if you bind the treeview to a collection in MudBlazor. I made a little demo for you to can play around online: https://try.mudblazor.com/snippet/cuwlvFQcfJTzHuki
Here is the full code of the example:
<MudButton OnClick="AddItems" Variant="Variant.Filled">Add items</MudButton>
<MudButton OnClick="DeleteItems" Variant="Variant.Filled">Delete items</MudButton>
<MudPaper Width="300px" Elevation="0">
<MudTreeView Items="TreeItems" MultiSelection="true" #bind-ActivatedValue="ActivatedValue" #bind-SelectedValues="SelectedValues">
<ItemTemplate>
<MudTreeViewItem #bind-Expanded="#context.IsExpanded" Items="#context.TreeItems" Value="#context"
Icon="#context.Icon" Text="#context.Title" EndText="#context.Number?.ToString()" EndTextTypo="#Typo.caption" />
</ItemTemplate>
</MudTreeView>
</MudPaper>
<div style="width: 100%">
<MudText Typo="#Typo.subtitle1">Activated item: #(ActivatedValue?.Title)</MudText>
<MudText Typo="#Typo.subtitle1">Sum of selected items: #GetSelectedSum()</MudText>
</div>
#code {
private TreeItemData ActivatedValue { get; set; }
private HashSet<TreeItemData> SelectedValues { get; set; }
private HashSet<TreeItemData> TreeItems { get; set; } = new HashSet<TreeItemData>();
public class TreeItemData
{
public string Title { get; set; }
public string Icon { get; set; }
public int? Number { get; set; }
public bool IsExpanded { get; set; }
public HashSet<TreeItemData> TreeItems { get; set; }
public TreeItemData(string title, string icon, int? number = null)
{
Title = title;
Icon = icon;
Number = number;
}
public override bool Equals(object x) {
var other = x as TreeItemData;
if (other==null)
return false;
return other.Title==Title;
}
public override int GetHashCode() {
return Title.GetHashCode();
}
}
protected override void OnInitialized()
{
TreeItems.Add(new TreeItemData("All Mail", Icons.Filled.Email));
TreeItems.Add(new TreeItemData("Trash", Icons.Filled.Delete));
TreeItems.Add(new TreeItemData("Categories", Icons.Filled.Label)
{
IsExpanded = true,
TreeItems = new HashSet<TreeItemData>()
{
new TreeItemData("Social", Icons.Filled.Group, 90),
new TreeItemData("Updates", Icons.Filled.Info, 2294),
new TreeItemData("Forums", Icons.Filled.QuestionAnswer, 3566),
new TreeItemData("Promotions", Icons.Filled.LocalOffer, 733)
}
});
TreeItems.Add(new TreeItemData("History", Icons.Filled.Label));
}
public int GetSelectedSum()
{
return SelectedValues?.Sum(i => i.Number ?? 0) ?? 0;
}
private int i=0;
public void AddItems() {
TreeItems.Add(new TreeItemData("Added Item " + (i++), Icons.Filled.Coronavirus));
}
public void DeleteItems() {
var item=TreeItems.FirstOrDefault(x=>x.Title.StartsWith("Added Item"));
TreeItems.Remove(item);
}
}

How I can pass data from Controller to Views on Blazor?

I try create a project using Blazor(server-side) and create the views as .razor, and I also add the Controller. How can I pass data from controller to views .razor ?
I think I can create a public variable in the controller, that will be interaction Controller and .razor. But I don't know for the Code
I want get var u to the view
//Controller
[HttpPost("[action]")]
public void Save(IList<IFormFile> UploadFiles)
{
var u = UploadFiles.FirstOrDefault().FileName;
long size = 0;
size = SaveUploadedFiles(UploadFiles, size);
}
//View
<EjsUploader ID="UploadFiles">
<UploaderAsyncSettings SaveUrl="api/Save" RemoveUrl="api/Remove"></UploaderAsyncSettings>
</EjsUploader>
Syncfusion support here.
You can pass the data from the controller either using “Headers” or “ReasonPhrase” to the view in the success event as mentioned in the below code example.
[SampleDataController.cs]
public void Save(IList<IFormFile> UploadFiles)
{
long size = 0;
try
{
foreach (var file in UploadFiles)
{
var filename = ContentDispositionHeaderValue
.Parse(file.ContentDisposition)
.FileName
.Trim('"');
filename = hostingEnv.ContentRootPath.Replace("WebApplication6.Server", "WebApplication6.Client") + $#"\{filename}";
size += (int)file.Length;
if (!System.IO.File.Exists(filename))
{
using (FileStream fs = System.IO.File.Create(filename))
{
file.CopyTo(fs);
fs.Flush();
}
}
}
Response.Headers.Add("custom-header", "Syncfusion");
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "Syncfusion Upload";
}
catch (Exception e)
{
Response.Clear();
Response.StatusCode = 204;
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = "File failed to upload";
Response.HttpContext.Features.Get<IHttpResponseFeature>().ReasonPhrase = e.Message;
}
}
[index.razor]
#using Newtonsoft.Json;
#using Newtonsoft.Json.Converters;
<EjsUploader Id="UploadFiles" AutoUpload="true" Success="#OnSuccess">
<UploaderAsyncSettings SaveUrl="api/SampleData/Save" RemoveUrl="api/SampleData/Remove"></UploaderAsyncSettings>
</EjsUploader>
<p>Additional Header Text is: #HeaderData</p>
<p>Additional Response Data is: #ResponseData</p>
#code{
public string HeaderData;
public string ResponseData;
public void OnSuccess(object args)
{
SuccessEventArgs eventArgs = JsonConvert.DeserializeObject<SuccessEventArgs>(args.ToString());
HeaderData = eventArgs.Response.Headers;
ResponseData = eventArgs.Response.StatusText;
this.StateHasChanged();
}
//Success event args class.
public class SuccessEventArgs
{
public object E { get; set; }
public FileInfo File { get; set; }
public string StatusText { get; set; }
public string Name { get; set; }
public string Operation { get; set; }
public ResponseEventArgs Response { get; set; }
}
public class ResponseEventArgs
{
public string Headers { get; set; }
public object ReadyState { get; set; }
public object StatusCode { get; set; }
public string StatusText { get; set; }
public bool withCredentials { get; set; }
}
}
And, you need to enable the allow header option in the Startup.cs file as mentioned in the below code example.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().AddNewtonsoftJson();
services.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});
services.AddCors(options =>
{
options.AddPolicy("EnableCORS", builder =>
{
builder.AllowAnyOrigin().AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod().AllowCredentials().Build();
});
});
}
We have prepared the sample and attached below.
Sample Link:
https://www.syncfusion.com/downloads/support/directtrac/242743/ze/WebApplication6_additional_data-460323506
Also, currently we are working on to provide the specific type for success event arguments and this support will be included in our patch release scheduled on mid of August 2019. We appreciate your patience until then.
You can track the status of the issue from the below feedback link.
Link: https://www.syncfusion.com/feedback/7647/need-to-provide-specific-type-for-success-event-arguments-in-the-uploader

Best way to show all subfolders and its files in uwp

I have stored all subfolder names and it's corresponding file names(from local folder) in a class. Now I want to display it in a good way. And also need to access that files when user selects it. What is the best way to achieve it?
public class SubFolders
{
public string ItemName { get; set; }
public ObservableCollection<SubFolderFiles> SubItemsList { get; set; }
}
public class SubFolderFiles
{
public string SubItemName { get; set; }
}
Best way to show all subfolders and its files in uwp.
For this requirement, you need to create a relatively complete model like the following Illustration.
The above is recursive model, and I have make a class to match it.
public class Folder
{
public string FolderName { get; set; }
private ObservableCollection<File> _subFiles;
public ObservableCollection<File> SubFiles
{
get { return _subFiles ?? (_subFiles = new ObservableCollection<File>()); }
set
{
_subFiles = value;
}
}
private ObservableCollection<Folder> _subFolder;
public ObservableCollection<Folder> SubFolders
{
get { return _subFolder ?? (_subFolder = new ObservableCollection<Folder>()); }
set
{
_subFolder = value;
}
}
public Folder()
{
}
}
public class File
{
public string FileName { get; set; }
}
As you know, if you want to display the folders and files where in one folder on the ListView, you need to converter them into abstract listview items.
public class Item
{
public string ItemName { get; set; }
public ItemType IType { get; set; }
}
public enum ItemType
{
File,
Folder
}
Usage
FolderService.cs
public class FolderService
{
// private Folder FolderModel;
public async static Task<Folder> GetFolderInfoAsync(StorageFolder SelectFolder)
{
var FolderModel = new Folder();
FolderModel.FolderName = SelectFolder.Name;
IReadOnlyList<StorageFile> fileList = await SelectFolder?.GetFilesAsync();
foreach (StorageFile file in fileList)
{
var subFile = new File();
subFile.FileName = file.Name;
FolderModel.SubFiles.Add(subFile);
}
IReadOnlyList<StorageFolder> folderList = await SelectFolder?.GetFoldersAsync();
foreach (StorageFolder folder in folderList)
{
var subFolder = new Folder();
subFolder.FolderName = folder.Name;
FolderModel.SubFolders.Add(subFolder);
}
return FolderModel;
}
public async static Task<ObservableCollection<Item>>GetItems(StorageFolder SelectFolder)
{
var Model = await GetFolderInfoAsync(SelectFolder);
var Items = new ObservableCollection<Item>();
foreach (var file in Model.SubFiles)
{
var item = new Item
{
ItemName = file.FileName,
IType = ItemType.File
};
Items.Add(item);
}
foreach (var folder in Model.SubFolders)
{
var item = new Item
{
ItemName = folder.FolderName,
IType = ItemType.Folder
};
Items.Add(item);
}
return Items;
}
}
ManPageViewModel.cs
public class MainViewModel : INotifyPropertyChanged
{
public MainViewModel()
{
}
public Command PickCommand => new Command(() => this.BtnClick());
private async void BtnClick()
{
StorageFolder Selectfolder = ApplicationData.Current.LocalFolder;
this.Items = await FolderService.GetItems(Selectfolder);
}
private ObservableCollection<Item> _items;
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged([CallerMemberName] string PropertyName = null)
{
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(PropertyName));
}
public ObservableCollection<Item> Items
{
get { return _items; }
set
{
_items = value;
OnPropertyChanged();
}
}
}

how to perform specific action on submit button in asp.net mvc4

I am working with Dual ListBoxes and using two buttons to move data from one listbox to another..
Here following code I have done to move data from one Listbox to another
InstituteInformation.cs
public class InstituteInformation
{
public int Id { get; set; }
public string InstituteName { get; set; }
}
MemberAccessRights.cs
public class MemberAccessRights
{
public int Id { get; set; }
public List<InstituteInformation> AvailableNames { get; set; }
public int[] AvailableSelected { get; set; }
public List<InstituteInformation> RequestedNames { get; set; }
public string[] RequestedSelected { get; set; }
public string SavedRequested { get; set; }
}
//Controller
//
// GET: /MemberDetails/Create
public ActionResult Create()
{
Wrapper1 MD = new Wrapper1();
MD.MAR = new MemberAccessRights{ AvailableNames = getAllInstituteNameList(), RequestedNames = new List<InstituteInformation>() };
return View(MD);
}
//
// POST: /MemberDetails/Create
[HttpPost]
public ActionResult Create(Wrapper1 MD, string add, string remove)
{
try
{
ModelState.Clear();
RestoreSavedState(MD);
if (!string.IsNullOrEmpty(add))
AddNames(MD);
elseif (!string.IsNullOrEmpty(remove))
AddNames(MD);
SaveState(MD);
using (varMDConext = new WrapperDB())
{
MDConext.MBIDBS.Add(MD.MBI);
MDConext.MACDBS.Add(MD.MAC);
MDConext.MARDBS.Add(MD.MAR);
MDConext.MODBS.Add(MD.MO);
}
returnRedirectToAction("Index");
}
catch
{
return View(MD);
}
}
#regionSupportFuncs
void SaveState(Wrapper1 MD)
{
MD.MAR.SavedRequested = string.Join(",", MD.MAR.RequestedNames.Select(p =>p.Id.ToString()).ToArray());
////Available Names = All - Requested
MD.MAR.AvailableNames = getAllInstituteNameList().Except(MD.MAR.RequestedNames).ToList();
}
//RestoreSavedState
void RestoreSavedState(Wrapper1 MD)
{
MD.MAR.RequestedNames = newList<InstituteInformation>();
if (!string.IsNullOrEmpty(MD.MAR.SavedRequested))
{
string[] nameids = MD.MAR.SavedRequested.Split(',');
var name = getAllInstituteNameList().Where(p =>nameids.Contains(p.Id.ToString()));
MD.MAR.RequestedNames.AddRange(name);
}
}
//AddNames
void AddNames(Wrapper1 MD)
{
if (MD.MAR.AvailableSelected != null)
{
var names = getAllInstituteNameList().Where(p =>MD.MAR.AvailableSelected.Contains(p.Id));
MD.MAR.RequestedNames.AddRange(names);
MD.MAR.AvailableSelected = null;
}
}
//RemoveNames
void RemoveNames(Wrapper1 MD)
{
if (MD.MAR.RequestedSelected != null)
{
MD.MAR.RequestedNames.RemoveAll(p =>MD.MAR.RequestedSelected.Contains(p.Id.ToString()));
MD.MAR.RequestedSelected = null;
}
}
#endregion
View
List of Financial Institute
<%:Html.ListBoxFor(model=>model.MAR.AvailableSelected,new MultiSelectList(Model.MAR.AvailableNames,"Id","InstituteName",Model.MAR.AvailableSelected)) %>
<div>
<input id="add" name="add" type="submit" value=">>" />
<br />
<input id="remove" name="remove" type="submit" value="<<" />
</div>
<%:Html.ListBoxFor(m=>m.MAR.RequestedSelected,new MultiSelectList(Model.MAR.RequestedNames,"Id","Name",Model.MAR.RequestedSelected)) %>
But there is the problem is that when I click on add(>>) or remove(<<) button the action is performed on the complete page just like the submit button which save the data from that page to db. Here I wanted to know how to perform the action button after clicking the add(>>) or remove(<<) button.
please help to solve this
The idea was that a form could contain more than one submit button issuing a form post to a different way.

Categories

Resources