First to remember that when we pass array, List or any collection from controller to view then must to add model with IEnumerable<type> . Here IEnumerable refer to collection. After that you can retrieve items using for-each loop.
Friday, June 16, 2017
Thursday, June 15, 2017
Create RadioButtonList, Get selected value From RadioButtonList in ASP.NET Core
A RadioButtonList have some multiple radio buttons , I mean to say that using loop its looking like a RadioButtonList. In ASP.NET CORE 1.1 , MVC we have to show you, how to create a Radio Button List in it. We have to show you an Example of RadioButton List in ASP.NET CORE.
Tuesday, May 16, 2017
ASP.NET Hindi Video Tutorials
यदि आप ASP.NET WEBFORM सीखना चाहते हैं तो आप यह प्लेलिस्ट का उपयोग कर सकते हैं | इस प्लेलिस्ट के अन्दर आपको शुरुवात से बताया जायेगा की आपको कैसे विसुअलस्टूडियो को ओपन करना कैसे उसके विंडोज जैसे की सलूशन एक्स्प्लोरर , टूलबॉक्स, सरवर एक्स्प्लोरर इत्यादि को कैसे काम में लेना हैं |
इस प्लेलिस्ट के अन्दर हर उस कण्ट्रोल का विडियो बनाया गया हैं जो की टूलबॉक्स में उपस्थित हैं | जैसे की ड्रापडाउनलिस्ट, लिस्त्बोक्स, चेकबॉक्स, रेडियोबटन इतियादी |
इस प्लेलिस्ट में आपको बताया जायेगा की फ्रंट एंड एप्लीकेशन को बेकएंड एप्लीकेशन से कैसे जोड़ा जाता हैं कहने का मतलब हैं डाटाबेस की कनेक्टिविटी कैसे की जाती हैं |
Dynamic एप्लीकेशन पर कैसे StyleSheet और कैसे थीम को कनेक्ट किया जाता हैं | Entity Framework को पूरा हिंदी में सिख सकते हैं | LINQ को हिंदी में सिख सकते हैं | Validation कण्ट्रोल क्या होते हैं कैसे उनका उपयोग किया जाता हैं सब कुछ सिर्फ इस एक प्लेलिस्ट के माध्यम से सिख सकते हैं |
Thursday, March 23, 2017
How to create Database in ASP.NET CORE 1.1 using model first
Technology changes, code optimization, newly design asp.net core 1.1. This article i wrote for you who want to make database in asp.net core 1.1, its a very simple technique provide by Microsoft developers. Thanks guys. Let start how to do this, you can follow these steps to design database in it.
Step-1: Create a new project in ASP.NET CORE using Visual Studio 2017 by the using following picture
Step-2: In Model folder, add a new Student.cs class. Add some properties in it. But make sure , one primary key have in it.
Step-3: Similarly in previous make, a new DataContext class for communicating table.
Check this video for full details
Step-1: Create a new project in ASP.NET CORE using Visual Studio 2017 by the using following picture
Step-2: In Model folder, add a new Student.cs class. Add some properties in it. But make sure , one primary key have in it.
Step-3: Similarly in previous make, a new DataContext class for communicating table.
Check this video for full details
Friday, July 15, 2016
JQuery Notification bar on top of the page
JQuery Notification bar on Top of the web page. This is the new thing in the mind i.e when we click on hyperlink then show a division with some message on top of the web page. The logic behind the thing is too much simple, In JQuery we have two method slideUp( ) and slideDown( ) , which are used for animation. In this article , i have used both.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JQuery: Notification bar Example </title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$("#Button1").click(function () {
$("#NotificationDiv").slideUp('slow');
});
$("#ShowNotificationBar").click(function () {
$("#NotificationDiv").slideDown('slow');
});
});
</script>
<style>
.NotficationBar{
background-color:blue;
color:white;
position:absolute;
width:100%;
top:0px;
left:0px;
text-align:center;
border-bottom-width:3px;
border-bottom-color:#000000;
border-bottom-style:solid;
padding:15px;
}
</style>
</head>
<body>
<div id="NotificationDiv" class="NotficationBar">
<label>Welcome to dotprogramming.blogspot.com</label>
<br/>
<input type="button" id="Button1" value="close"/>
</div>
<div>
<a href="" id="ShowNotificationBar">Show Notification Bar </a>
</div>
</body>
</html>
Application of the article:
- If you want to give special notice on website then you can use it.
- Use it in Current News Section.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JQuery: Notification bar Example </title>
<script src="Scripts/jquery-1.10.2.js"></script>
<script>
$(function () {
$("#Button1").click(function () {
$("#NotificationDiv").slideUp('slow');
});
$("#ShowNotificationBar").click(function () {
$("#NotificationDiv").slideDown('slow');
});
});
</script>
<style>
.NotficationBar{
background-color:blue;
color:white;
position:absolute;
width:100%;
top:0px;
left:0px;
text-align:center;
border-bottom-width:3px;
border-bottom-color:#000000;
border-bottom-style:solid;
padding:15px;
}
</style>
</head>
<body>
<div id="NotificationDiv" class="NotficationBar">
<label>Welcome to dotprogramming.blogspot.com</label>
<br/>
<input type="button" id="Button1" value="close"/>
</div>
<div>
<a href="" id="ShowNotificationBar">Show Notification Bar </a>
</div>
</body>
</html>
Saturday, June 25, 2016
jQuery Autocomplete List appear onFocus TextBox
In this example i will show you, How to show array list when we focus on TextBox. I mean to say that array list contain users name and its show when we focus on TextBox. Here we have a simple example which is contain list of users name, also i have a autocomplete function in Script library . I have a video , you can check for implementation as well as output.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0-rc.2/themes/base/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.11.3.js"></script>
<script src="//code.jquery.com/ui/1.12.0-rc.2/jquery-ui.min.js"></script>
<script>
$(function () {
var users = ['jacob lefore', 'Bill', 'smith wick', 'ammey', 'rodkils', 'BillSmith'];
$('#TextBox1').autocomplete({
source: users,
minLength:0
}).focus(function () {
$(this).autocomplete("Search", "");
})
})
</script>
</head>
<body>
Enter name: <input type="text" id="TextBox1" placeholder="TextBox Focus"/>
</body>
</html>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.0-rc.2/themes/base/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.11.3.js"></script>
<script src="//code.jquery.com/ui/1.12.0-rc.2/jquery-ui.min.js"></script>
<script>
$(function () {
var users = ['jacob lefore', 'Bill', 'smith wick', 'ammey', 'rodkils', 'BillSmith'];
$('#TextBox1').autocomplete({
source: users,
minLength:0
}).focus(function () {
$(this).autocomplete("Search", "");
})
})
</script>
</head>
<body>
Enter name: <input type="text" id="TextBox1" placeholder="TextBox Focus"/>
</body>
</html>
Wednesday, June 15, 2016
How to use FileUpload Control in ASP.NET
Introduction
The FileUpload control displays a text box control and a browse button that enable users to browse a file from the local or remote machine to upload it on the Web server. You can upload a file on the Web Server by specifying the full path of the file to be uploaded (for example D:\Myfiles\Test.txt) in the textbox of this control . Alternatively , you can select the file by clicking the browse button , and then locating it in the Choose File dialog box.
Public Properties of the FileUpload Class
FileBytes : Obtains an array of the bytes in a file that is specified by using a FileUpload control
FileContent : Obtains a Stream object that points to a file to upload using the FileUpload control.
FileName : Obtains the name of a file on a client to upload using the FileUpload control.
HasFile : Obtains a value indicating whether the FileUpload control contains a file.
PostedFile : Obtains the underlying HttpPostedFile object for a file that is uploaded by using the FileUpload control.
Public Method of the FileUpload Class
SaveAs : Saves the data of an uploaded file to a specified path on the web server.
Example of FileUpload control in ASP.NET
Multiple File Upload control on Same Page
This is the new features comes into the DOTNET Framework 3.5. If you have three or more file upload control on same page then what to do for save files into project directory. If you use traditional code like
if(fileupload1.hasfile)
{
//code)}
if(fileupload2.hasfile)
{
//code
}
This is the wrong for developer perspective. You can use new features of DOTNET Framework 3.5 i.e HttpFileCollection class. By using Request.Files property you can get the files from the server.
Check the simple example of it.
Source Code:
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:FileUpload ID="FileUpload2" runat="server" />
<br />
<asp:FileUpload ID="FileUpload3" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "E:\\Upload";
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
try
{
if (hpf.ContentLength>0)
{
Label1.Text += "File Content Type: " + hpf.ContentType+"<br/>";
Label1.Text += "File Size: " + hpf.ContentLength + "<br/>";
Label1.Text += "File Name: " + hpf.FileName + "<br/>";
hpf.SaveAs(filepath + "\\" + System.IO.Path.GetFileName(hpf.FileName));
Label1.Text += "Location of the file: " + filepath + "\\" + System.IO.Path.GetFileName(hpf.FileName);
}
}
catch (Exception ex)
{
Label1.Text += "Error: " + ex.Message;
}
}
}
Code Generate the following output:
The FileUpload control displays a text box control and a browse button that enable users to browse a file from the local or remote machine to upload it on the Web server. You can upload a file on the Web Server by specifying the full path of the file to be uploaded (for example D:\Myfiles\Test.txt) in the textbox of this control . Alternatively , you can select the file by clicking the browse button , and then locating it in the Choose File dialog box.
Top Related article
- Fileupload control enable disable programmatically in ASP.NET
- Programmatically change border color of fileupload control in ASP.NET
- Programmatically change background color of fileupload control in ASP.NET
- How to validate fileupload control in asp.net also choose selected format
- How to insert image into database using file upload control
Public Properties of the FileUpload Class
FileBytes : Obtains an array of the bytes in a file that is specified by using a FileUpload control
FileContent : Obtains a Stream object that points to a file to upload using the FileUpload control.
FileName : Obtains the name of a file on a client to upload using the FileUpload control.
HasFile : Obtains a value indicating whether the FileUpload control contains a file.
PostedFile : Obtains the underlying HttpPostedFile object for a file that is uploaded by using the FileUpload control.
Public Method of the FileUpload Class
SaveAs : Saves the data of an uploaded file to a specified path on the web server.
Example of FileUpload control in ASP.NET
<%@ Page Language="C#" %>
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/images/" + FileUpload1.FileName));
}
else
{
emptyupload.Text = "Choose your file";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
font-size: larger;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="auto-style1">
<strong>Pick Your file from file upload control<br />
</strong>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />
<br />
<asp:Label ID="emptyupload" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Output
<!DOCTYPE html>
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~/images/" + FileUpload1.FileName));
}
else
{
emptyupload.Text = "Choose your file";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
font-size: larger;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="auto-style1">
<strong>Pick Your file from file upload control<br />
</strong>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Save" />
<br />
<asp:Label ID="emptyupload" runat="server"></asp:Label>
</div>
</form>
</body>
</html>
Only GIF image support by FileUpload control
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{ string extn=string.Empty ;
if (FileUpload1.HasFile)
{
extn = System.IO.Path.GetExtension(FileUpload1.FileName);
if ("gif" == extn)
{
FileUpload1.SaveAs(Server.MapPath("~/images/" + FileUpload1.FileName));
emptyupload.Text = "Save sucessfully";
}
else
{
emptyupload.Text = "only gif support";
}
}
else
{
emptyupload.Text = "Choose your file";
}
}
</script>
Note : GetExtension is the method of the path class which is detect extension of the filename. protected void Button1_Click(object sender, EventArgs e)
{ string extn=string.Empty ;
if (FileUpload1.HasFile)
{
extn = System.IO.Path.GetExtension(FileUpload1.FileName);
if ("gif" == extn)
{
FileUpload1.SaveAs(Server.MapPath("~/images/" + FileUpload1.FileName));
emptyupload.Text = "Save sucessfully";
}
else
{
emptyupload.Text = "only gif support";
}
}
else
{
emptyupload.Text = "Choose your file";
}
}
</script>
Multiple File Upload control on Same Page
This is the new features comes into the DOTNET Framework 3.5. If you have three or more file upload control on same page then what to do for save files into project directory. If you use traditional code like
if(fileupload1.hasfile)
{
//code)}
if(fileupload2.hasfile)
{
//code
}
This is the wrong for developer perspective. You can use new features of DOTNET Framework 3.5 i.e HttpFileCollection class. By using Request.Files property you can get the files from the server.
Check the simple example of it.
Source Code:
<div>
<asp:FileUpload ID="FileUpload1" runat="server" />
<br />
<asp:FileUpload ID="FileUpload2" runat="server" />
<br />
<asp:FileUpload ID="FileUpload3" runat="server" />
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" />
<br />
<asp:Label ID="Label1" runat="server"></asp:Label>
</div>
protected void Button1_Click(object sender, EventArgs e)
{
string filepath = "E:\\Upload";
HttpFileCollection hfc = Request.Files;
for (int i = 0; i < hfc.Count; i++)
{
HttpPostedFile hpf = hfc[i];
try
{
if (hpf.ContentLength>0)
{
Label1.Text += "File Content Type: " + hpf.ContentType+"<br/>";
Label1.Text += "File Size: " + hpf.ContentLength + "<br/>";
Label1.Text += "File Name: " + hpf.FileName + "<br/>";
hpf.SaveAs(filepath + "\\" + System.IO.Path.GetFileName(hpf.FileName));
Label1.Text += "Location of the file: " + filepath + "\\" + System.IO.Path.GetFileName(hpf.FileName);
}
}
catch (Exception ex)
{
Label1.Text += "Error: " + ex.Message;
}
}
}
Code Generate the following output: