Is there any way to display image in client browser without uploading it to server?

后端 未结 4 559
攒了一身酷
攒了一身酷 2021-01-24 01:57

I am writing a simple \"Book\" create page in ASP.NET MVC. User can create book by filling title,year etc.. and selecting a cover image. When user press \"Create\" button Form

4条回答
  •  醉梦人生
    2021-01-24 02:29

    Yes, using Silverlight, for example:

    In Page.xaml:

    
        

    and in Page.xaml.cs:

    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(Page_Loaded);
        }
    
        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            btn1.Click += new RoutedEventHandler(btn1_Click);
        }
    
        void btn1_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog() == true)
            {
                Stream s = ofd.File.OpenRead();
                BitmapImage bi = new BitmapImage();
                bi.SetSource(s);
                img1.Source = bi;
                s.Close();
            }
        }
    }
    

    Read more here.

提交回复
热议问题