-->

Thursday, October 22, 2015

WPF LISTVIEW BINDING USING EDMX FILE

In previous WPF listview article, I explained, how to bind listview from List of string type. In this article, I will explain you, how to bind listview using EDMX file. We all know about powerful features of  WPF listview i.e Gridview. Lets, take an example of it.

  <Grid>  
     <ListView Name="listgrid">  
       <ListView.View>  
         <GridView>  
           <GridViewColumn Header="Id" DisplayMemberBinding="{Binding Id}"/>  
           <GridViewColumn Header="Name" DisplayMemberBinding="{Binding Emp_Name}"/>  
         </GridView>          
       </ListView.View>     
     </ListView>  
   </Grid>  

In the mentioned code, Gridview is a view of WPF Listview with two columns that are Id and name. Here, DisplayMemberBinding is the property of GridviewColumn, which is used to bind listview columns from field of model class.

  public partial class MainWindow : Window  
   {  
     public MainWindow()  
     {  
       InitializeComponent();  
       loadlistview();  
     }  
     private void loadlistview()  
     {  
       DatabaseEntities dbe = new DatabaseEntities();  
       listgrid.ItemsSource = dbe.Employees.ToList();  
     }  
   }  

Here, DatabaseEntities, context class in EDMX model, also Employees is the public property in DataContext class. Learn How to add EDMX file with database file.
Now, code generate the following output:

WPF LISTVIEW BINDING USING EDMX FILE

ASP.NET FILEUPLOAD CONTROL INSERT IMAGE INTO DATABASE

Introduction

First of all, I would like to thank all of the readers who have read my previous articles. What a great support I have got from you people. By using ASP.NET File upload control, we can easily insert images into Table or you can say that we can create image gallery projects. With the help of JQuery, we put some dynamic effects like upload multiple files one by one. you can also do by JQuery to create button work as File upload. I really felt great when article Bind GridView was displayed on this blog page. Following are the articles that I have written so far for beginners as well as developers.



Follow some steps for inserting Images into database using asp.net fileupload control.

STEP-1 : Create Database Table

HOW TO INSERT IMAGE INTO DATABASE



STEP-2: Drag asp.net fileupload control from ToolBox and Drop it in Design window.


  <form id="form1" runat="server">  
   <div>  
     <asp:FileUpload ID="FileUpload1" runat="server" /><BR />  
     <asp:Button ID="Button1" runat="server" Text="Submit" />  
     <br />  
     <br />  
     <asp:Label ID="Result" runat="server"></asp:Label>  
   </div>  
   </form>  

fileuploadcontrol
STEP 3: Make a new directory in website folder name as "upload".
STEP 4:  Double click on submit button and raise click event.

 using System;  
 using System.Collections.Generic;  
 using System.Linq;  
 using System.Web;  
 using System.Web.UI;  
 using System.Web.UI.WebControls;  
 using System.Data.SqlClient;  
 using System.Configuration;  
 using System.Data;  
 public partial class FILEUPLOAD : System.Web.UI.Page  
 {  
   protected void Page_Load(object sender, EventArgs e)  
   {  
   }  
   protected void Button1_Click(object sender, EventArgs e)  
   {  
     string imagedata = string.Empty;  
     if (FileUpload1.HasFile)  
     {  
       FileUpload1.SaveAs(Server.MapPath("~/upload/" + FileUpload1.FileName));  
       imagedata = "~/upload/" + FileUpload1.FileName;  
     }  
     using (SqlConnection con = new SqlConnection())  
     {  
       con.ConnectionString =ConfigurationManager .ConnectionStrings ["ConnectionString"].ToString ();  
       con.Open ();  
       using (SqlCommand cmd=new SqlCommand ())  
       {  
         cmd.Parameters.AddWithValue("@ur", imagedata);  
         cmd.CommandText ="insert into imagedata(url) values(@ur)";  
         cmd.Connection =con;  
         if (string.IsNullOrEmpty(imagedata))  
         {  
           Result.Text = "choose right image";  
         }  
         else  
         {  
           int a = cmd.ExecuteNonQuery();  
           if (a > 0)  
             Result.Text = "data inserted";  
           else  
             Result.Text = "failed";  
         }  
       }  
     }  
   }  
 }  

Output of the program
How to insert image into database using file upload control

How to insert image into database using file upload control
Here, first to insert images in website folder also get the File path during fileupload. Now, insert the file into Table as like Text. 

Update Edmx When Database Changes in MVC 4

MVC 4: Update Edmx is to make the model as same as the database through which it created. Whatever changes made with the database will not reflect in the Model to perform CURD functions. Suppose we have added a new table with SQL server management studio and want to insert/update some entries with that table using code part. After creating object of database context, notice that we don’t have an instance for that newly added table. To resolve this issue we have to update our edmx using Update Model Wizard as described in this article.

Create new table Category in the same database added earlier and use basic columns like id, name, description, isActive. Open our visual studio project and check that this table have not any existence yet. Open edmx file, right click on the blank space and click on Update Model from Database.

Update Model from Database





  An Update Model wizard will open with options to add tables, views and stored procedures. We have added only a table so expand “Tables” node and select “Categories”. Leave remaining options as they are and click finish.


expand “Tables” node and select “Categories


 After finishing it will reload and will add newly added table, check the edmx file and there are two tables Employee and Categories as shown in below image.

check the edmx file


This update model wizard does following in MVC 4:
  • If a table removed from database, it will remove from the model also and update mapping details.
  • If table has been added, it will insert new object in the existing model and update mapping details.
  • Any modification in the object, this wizard will update the model like to add/remove columns.

Wednesday, October 21, 2015

Top 10 asp.net forums

Asp.net forums: It mean provide help related to asp.net code and many more things like presentation related, business logic related etc. asp.net support many languages like c#, f#, vb etc. These languages are interoperable so all mentioned forums are working in all languages.

(Top-1)asp.net forums: This is related to many more things like tutorials, articles, learning skills, asp.net forums etc. Forums working on these following topics:

  1. Getting started: general awareness of asp.net.
  2. web forms:   Server controls, events, validation, master pages, themes, web parts, personalization, etc.
  3. Web Forms Data Controls : Data-bound controls such as the GridView, DataGrid, DataList, FormView, DetailsView, Repeater, and Microsoft Chart.
  4. MVC: Discussions regarding ASP.NET Model-View-Controller (MVC).
Alexa Traffic Rank




(Top-2)stack overflow: This is related to various technologies like asp.net, php, javascript, c++, java, mysql, css, html, python etc. Put your thread related to tag.

stack overflow alexa rank


(Top-3)c-sharpcorner : Uncategorized asp.net forums, in this you can put your thread and get answers from other developers of people.

Alexa rank: Global rank- 4864

(Top-4) asp.net forums : Simple categories forum in different technologies like DOTNET Framework, asp.net, Database, html,css and java script. First to register in it and put your thread in specific category.

Alexa Rank : Global rank - 83681

(Top-5) newly start forum: This forum is newly started, if you join this then you get golden membership. It categories in differeent sub categories like ASP.NET, AJAX, WEB FORMS, MVC, WEB SERVICE, JQUERY.

Alexa rank : Global rank - 6,20,230

(Top-6) dotnet spider : Before posting any thread in it, make register, register button available in top right corner. Fill all reguired fields, do login by their username and psasword. If you want to post your thread here then select forum from navigation, select respective forum.

Alexa rank : Global rank - 55, 428

(Top-7)Dotnet funda: Similarly in this, we can put thread for other users. Joining is so simple and sweet, first to register, confirm email by your mail box, login by their username and password. Select category under forum tab.

Alexa rank : Global rank- 27,602

(Top-8) Tutorialized Forum: You can start threading by your errors/doubts. Interesting thing in this forum, if you are new user for this forums then you can not allow to submit url.

Alexa rank:  Global rank - 82,259

(Top-9) Discountasp.net : Discount asp.net forums share current news and updates which is related to asp.net. Provide various services to the users like getting started, hosting services, general trubleshooting, control panel etc. Before reply to any thread, you have full permissions.

Alexa rank:  Global rank- 99,677

(Top-10) developer fusion :  This forum contain both licence and open source contents, i mean to say catogries realted to all technology like java, asp.net etc.

Alexa rank : Global rank- 71,191

Refactoring in visual studio 2013,2015

Refactoring, change the internal structure of the code without any changes in behavior/outer structure. By using visual studio plugins, you can do the following refactoring in the visual studio code. The most popular and powerful refactoring plugin/extension in visual studio is visual assist. By using it, we can do some following tasks:

  • Extract method refactoring: By using visual studio we can create new methods for existing code, I want to say that if you have a code in a method, you want to break it in different segments/methods then you can use extract method like Suppose your code look like
   public class Class1  
   {  
     public void display()  
     {  
       int a=10;  
       int b=20;  
       Console.WriteLine(a + b);  
     }  
   }  

Select the code fragment you want to extract:

  int a=10;  
       int b=20;   

Right click on selected text, Refactor--> Extract Method..., appear new window.

Extract method window in visual studio

After pressing the "ok" button, your code look like

  public class Class1  
   {  
     public void display()  
     {  
       int a;  
       int b;  
       NewMethod(out a, out b);  
       Console.WriteLine(Convert.ToString(a+b));  
     }  
     private static void NewMethod(out int a, out int b)  
     {  
       a = 10;  
       b = 20;  
     }  
   }  

  • Change class name also the file name: If you want to change class name after creating code then you can do this by replacing. But, file name doesn't change. So, try visual assist to change the class name, constructor name, and file name.    
Right click on class name, select Refactor(VA)--Rename to change the class name also file name.


After do this, your code and file:

Change class name also the file name

Tuesday, October 20, 2015

VISUAL STUDIO DESIGN GAMES USING UNITY PLUGINS

Microsoft and many more product based companies provides some extensions for visual studio. Behind the scene, the main purpose of them, they want to enhance the features of visual studio. Similarly, UNITY software is a type of extension, which is used for design games in visual studio. UNITY provides you to make platform independent games, i mean, you can run your games data in 21 platforms. Also provides many more features like:
  1. You can design your games either in 2D and 3D.
  2. Debug your game code using break point in visual studio.
  3. You can put your logics in UNITY game by using c#, which is userfriendly for you.
  4. Check error in error list of visual studio. 

How to download it: Download it by using official sites, but i recommended this path, Through this you can download other things. Download UnityDownloadAssistant-5.2.1f1.exe, start it by using double click. Below mentioned Progress snap  of downloading. 

unity download installer

In the next article i will show you how to start screen of unity, how to start codes in it and many more things.

Monday, October 19, 2015

Design beautiful web forms in any technology

Good morning, i am jacob, Today i have to share some post which is related to design beautiful web forms in asp.net. If you want to design web forms in asp.net then you need to learn some basic technologies like HTML, CSS, Photoshop, JQuery etc. Here, i will tech you about these technologies one by one using some web forms article. so, lets start, Following these steps to design beautiful we forms:
(Task-1)Before anything doing, must to rough stretch your website : Suppose you want to design 20 pages website then  you need 20 pages of note book. Now, stretch each web site page into your notebook. Suppose i have to design first page in my note book that is:

design beautiful web forms

Similarly do for all remaining pages. Now, your first task is completed.

(Task-2)Fill colors in stretched design: Now, come to second task that is fill colors, For beautiful web forms, must to fill different colors in the page by using color pens.

(Task-3)Design your pages by using Photoshop: By using Photoshop, you can feel exact look of your theme. So, Read some how to: articles about Photoshop by using googling. 

(Task-4)Now, start to design beautiful web forms in HTML from first page of your stretch/Photoshop page: Here, i have use web forms design in asp.net, so you need to read some article about asp.net master page. By using master page you can design your layout of all beautiful web forms.
Read more article about master page : need of master page and themes in asp.net

(Task-5) Fill colors and make responsive your design by using CSS3: if you want to design responsive and beautiful web forms then you need to learn CSS(Cascading Style Sheet). Here, i have demo of style sheet.

(Task-6) Put some Dynamic effects using JQuery into your web forms: If you have some pages which is related to login/register then use JQuery to put some dynamic effects like shadow, popups etc. I have some examples, which is related to dynamic effects like:
Dynamic effects using JQuery :  Show login form in popup using JQuery.
© Copyright 2013 Computer Programming | All Right Reserved