Skip to main content

Posts

Showing posts from December, 2015

Featured Post

How to use Tabs in ASP.NET CORE

I want to show Components in a tabs , so first of all create few components. In this project we have three components, First View Component  public class AllViewComponent : ViewComponent     {         private readonly UserManager<ApplicationUser> _userManager;         public AllViewComponent(UserManager<ApplicationUser> userManager)         {             _userManager = userManager;         }         public async Task<IViewComponentResult> InvokeAsync()         {             List<StudentViewModel> allUsers = new List<StudentViewModel>();             var items = await _userManager.Users.ToListAsync();             foreach (var item in items)             {                 allUsers.Add(new StudentViewModel {Id=item.Id, EnrollmentNo = item.EnrollmentNo, FatherName = item.FatherName, Name = item.Name, Age = item.Age, Birthdate = item.Birthdate, Address = item.Address, Gender = item.Gender, Email = item.Email });             }            

Item add at first | 0 index After Bind ASP.NET DropDownList using c#

In this article, I will show you how to add item at 0 index after bind DropDownList in ASP.NET C#. I will give an simple example of it. First to bind the DropDownlist with the DataSource then you can use Insert method to add item at any position. Insert( ) method overloads with 4 parameters. You can use third option, in which we have two parameters first for Text and second for value. Lets start to do: Create a Database table with the following fields:  CREATE TABLE [dbo].[user_table] (     [Id]       INT           IDENTITY (1, 1) NOT NULL,     [username] NVARCHAR (50) NULL,     [Password] NVARCHAR (50) NULL,     [email]    NVARCHAR (50) NULL,     PRIMARY KEY CLUSTERED ([Id] ASC) ); 1. Add a new web form in the project. 2. Bind it with the mentioned table using SqlDataReader class.  3. After bind you can use insert method. using System; using System.Collections.Generic; using System.Data.SqlClient; using System.Linq; using System.Web; us

ASP.NET RSS Feeds Display | Get

In this article, I will show you, How to display RSS feeds on your website. Actually, RSS feeds is an XML file. In ASP.NET we can create it easily through generic handlers . By using XmlTextWriter class, we can create XML file and XmlTextReader class we can read XML file. In this article, I will use XmlTextReader class to read it. Complete Source Code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReadRss.aspx.cs" Inherits="ReadRss" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>         <asp:Button ID="Button1" runat="server" Text="Read Rss" OnClick="Button1_Click" Width="163px" />     </div>         <asp:Repeater ID="Repeater1"

ASP.NET : How to use image in error message in validation Control

If you are generating error  message to the client side then you can use any type of validation in given ToolBox such as RequiredField validator , compare validator , custom validator etc. If you want to use Image for easy understand then you should insert image in Text property of the validation control.  <asp:RequiredFieldValidator  ControlToValidate ="TextBox1" Text="<img width='40px' height='40px' src='error.jpg' />" ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator"></asp:RequiredFieldValidator> Here we have used HTML Image Tag inside Text property of control. Example <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body&g

ASP.NET Rss Feeds Create Database Table

In this Article, I will show you, How to create Rss feeds for your website article. Rss feed is a xml file so in this article, i will create a XML file and Data pick from database table. Rss contains differenet filds link channel , article title, article description, link of the article and many more things. By using Rss feeds we can improve our search engine results , i mean to say we can improve our SEO of the website.  How to Start it: First of all create two table in the database, These are the fields which are mentioned below. If you are the beginners then i will provide you a short video through this you can create both table easily.  Also i will provide you scripts of table, through these you can directly create table into your database. CREATE TABLE [dbo].[Channel] (     [Id]          INT            IDENTITY (1, 1) NOT NULL,     [Title]       NVARCHAR (100) NULL,     [Description] NVARCHAR (MAX) NULL,     [Link]        NVARCHAR (100) NULL,     PRIMAR

How to change forecolor and backcolor dynamically of dropdownlist in ASP.NET

ForeColor and BackColor Change Dynamically Using the color property you can change your appearance of the Control. Looks is matter for any website if you do something different for your visitor or registered user. Your website visitor want that no one text hidden on the website. ForeColor : This is the TextColor which is appear in the DropDownlist . BackColor : This is the BackGround color. Example of the dynamically change forecolor and backcolor <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server">     protected void Button1_Click(object sender, EventArgs e)     {         DropDownList1.ForeColor = System.Drawing.Color.White;       }     protected void Button2_Click(object sender, EventArgs e)     {         DropDownList1.BackColor = System.Drawing.Color.Black;     } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title&

Solve Application not responding problem

In this article, I will show you how to fix computer hanging problems. Generally, we all know about "Not Responding" problem. When processor takes time to execute the process then thats type of problem occurs. By using this article, I will resolve this issue. Windows Form Design: using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication5 {     public partial class Form1 : Form     {         private readonly SynchronizationContext synchronizationContext;         private DateTime previousTime = DateTime.Now;         public Form1()         {             InitializeComponent();             synchronizationContext = SynchronizationContext.Current;         }         private void button1_Click(object sender, EventArgs e)         {          

How to bind Bulleted List control in asp.net

Following some steps for binding bulleted list control using SqlDataSource In this article, I will show you, How to bind BulletedList in ASP.NET. In this article, I will take SQL DataSource control to bind it. ASP.NET Provide inbuilt control to bind any other control like ListBox, ComboBox, BulletedList. After bind it, it will look like list of unordered list of HTML.Lets  to Start how to bind it. I will Give you, video as well as code for this. Step-1 : Open visual studio Step-2:  Click  File-->New-->WebSite Step-3: Right click on website name in solution explorer, Add-->Add new item  Step-4: Make Database table  Step-5: Drag Bulleted list from toolbox and drop on design window. Step-6: Select Show smart tag of Bulleted list Step-7: On Bulledted list task click choose data source link Step-8: Select New DataSource from Data Source configuration wizard. Step-9: Select SQL Database from Data Source Configuration wizard

Example of Customized TabItem of TabControl in WPF

Customized Tab Item Example: Tab Item is the item control of Tab control. In this article, I will show you, how to add images, TextBlock and any other control inside TabControl. Also I will show you how to move Tab Control's tabs using buttons like Pre, Next, Get Item of Selected tab. When we press Previous button then next tab move to previous button. Similarly for all buttons.  <Window x:Class="WpfApplication9.tabcon"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         Title="tabcon" Height="300" Width="300">     <Grid>         <!--<TabControl>             <TabItem Header="First Item">                 <Label Content="Items in the first tab"/>             </TabItem>             <TabItem Header="Second Item"/>             <

Example of Context menu in WPF

Context Menu Introduction: Context menu means a window appear when we click on right button of mouse on selected Text. Today, we will design context menu with the help of WPF. Here, we will take a Input control with context menu also context menu contain MenuItem. XAML Code <Grid>         <RichTextBox >             <RichTextBox.ContextMenu>                 <ContextMenu>                     <MenuItem Command="Cut">                         <MenuItem.Icon>                             <Image Source="apple.png"/>                         </MenuItem.Icon>                     </MenuItem>                     <MenuItem Command="Copy">                         <MenuItem.Icon>                             <Image Source="grapes.png"/>                         </MenuItem.Icon>                     </MenuItem>                 </ContextMenu>              

AWT Frame close using close Button

In AWT Java we have a Frame class which is inherit from window class. If you are a beginner in AWT Java then you know that Frame doesn't close when we press close button of it. So, In last we pressed stop debugging button in Netbeans IDE. If you want to close Frame using Close button, which is see in top right corner of Frame then you should implement code for it.  Complete Java Code package awtframe; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; public class AWTFrame {     public AWTFrame()     {         Frame f1=new Frame("Welcome to Closing");         f1.setSize(500,500);         f1.setVisible(true);                 f1.addWindowListener(new WindowAdapter(){                         @Override             public void windowClosing(WindowEvent e)             {               System.exit(0);             }                     });                     }     public static void main(String[] a

How to pass data from controller to view in ASP.NET MVC

If you want to pass value from controller to view in asp.net MVC, we have two methods. The first method of it is ViewBag and last is ViewData, both are used to pass data from controller to view. ViewBag object creates a dynamic variable and ViewData creates a dynamic key like ViewState in ASP.NET.  Learn, How to use ViewBag in MVC for single variable as well as List<String> type variable.  In controller class, we used ViewBag.Dynamic_variable = "Value" and in View we used @ViewBag.Dynamic_Variable_Name. Also, learn how to pass value from controller to view using ViewData. Both objects doesnot generate compile time error.

Password Box example in WPF

If you want to design login control then must to set the special character in password box. Today, we will learn, how to design password box in WPF. In WPF, we have a PasswordBox tag in XAML , through this we can add Password box in WPF. I have a simple login control through you can see password control. The complete code of login control <Window x:Class="WpfApplication8.password"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         Title="password" Height="300" Width="300">     <Grid>          <StackPanel Margin="20">             <Label>Password Box Example</Label>             <WrapPanel>                 <Label>Username:</Label>                 <TextBox Width="100"/>             </WrapPanel>             <WrapPanel>

WPF common "enable all" checkbox in the top

Introduction In this WPF article, I will show you, single checkbox enable all other remaining checkboxes; if it is unchecked then remaining them also unchecked. To do this task, first of add single checkbox for all other checkboxes in the stack panel. Now, add other child checkboxes in nested stack panel. look at, simple xaml code view. <Window x:Class="WpfApplication8.MainWindow"         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"         Title="MainWindow" Height="350" Width="525">     <Grid>         <StackPanel Margin="10">             <Label FontWeight="Bold">Technical Skills</Label>             <StackPanel Margin="20,10">                 <CheckBox IsThreeState="True" Name="AllSelect" Checked="AllSelect_Checked"

How to add window media player in ASP.NET

Introduction In this article, I will show you how to play mp4 and WMV file in asp.net. To do this task first to install Silverlight into your computer by the following link. After installed Silverlight, add System.Web.Silverlight.dll file reference in the bin folder. Add media player component in ToolBox by using right click on toolBox. Right click on toolbox--> choose Items...--->.Net Framework Components--> Click on Browse Button also select System.Web.Sliverlight from uncompressed folder. Drag Media player control from ToolBox to Web Form. Set Required property that is mentioned below. Media Source = ~/movie/first.mp4 Here, we have movie folder. Download System.Web.Silverlight.dll file . Code generates the following output

Add multiple TextBox dynamically using Button click in ASP.NET C#

Introduction In this article, I will show you how to add multiple TextBox by using button click. When we press the button then add TextBox in the panel. Similarly again when we press the button then again TextBox add just after previous one. I will give you an example of add multiple TextBox dynamically in ASP.NET. Source code <body>     <form id="form1" runat="server">     <div>     </div>     </form> </body> Code Behind page using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class DynamicallyAdd : System.Web.UI.Page {     Panel panelforTextBox;     protected void Page_Load(object sender, EventArgs e)     {         Literal literal;         Label labelTextBox;         panelforTextBox = new Panel();         panelforTextBox.ID = "panelforTextBox";         panelforTextBox.BorderWidth =