Skip to main content

Posts

Showing posts from July, 2013

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 });             }            

How to get cell value from gridview in asp.net

Computer Programming : GridView, combination of rows and columns. Single row contains one or more then one cells. If you want to get cell value from GridView, select Gridview row first. After that you can get cell value/Text from selected rows. Step-1 : Bind GridView using SqlDataSource in ASP.NET Step-2 : Drag and drop one label control onto design window Step-3 : Select "Enable Selection" using show smart tag. Step-4 : Double click on Gridview and handle SelectedIndexChanged event protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)     {     } Step-6 : Write code for getting value from gridview cell  protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)     {         Label1 .Text =GridView1 .SelectedRow .Cells [2].Text ;     } Output Whole code <%@ Page Language="C#" AutoEventWireup="true" CodeFile="sqldatabindgrid.aspx.cs" Inherits="sqldatabindgrid&qu

How to bind GridView using SqlDataSource in ASP.NET

Step-1 : First design database table in visual studio Step-2 : Drag and drop GridView control from ToolBox to Design window Step-3 : Select Choose data source by show smart tag. Step-4 : Select SQL Database in Data Source Configuration wizard. Step-5 : Select your database by dropdownlist in "Choose your data connection" wizard  your connection string will appeared. Step-6 : Select Table or Column name using "Configure the select statement"  wizard. Step-7: Press Test Query button Step-8: Run your Application <%@ Page Language="C#" AutoEventWireup="true" CodeFile="sqldatabindgrid.aspx.cs" Inherits="sqldatabindgrid" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div&g

Specify relative positions of controls in window form C#

When a window form is open, working normally, all the controls are set as the programmer set them with their parent form, it means that form is in normal state. Resize the form and check that the controls still remains of the same size and additional space is blank on the form. Anchor property of the form is used to put the controls to its relative position on the form, means a control is automatically take its relative position as its parent control is resized. Each control has its four edges i.e. left, top, right and bottom. By default a control is added to the form with its Anchor property to top and left. When we resize a form then the control is still in top and left corner of the form and size of the control is fixed. For example drag and drop a listview in the form and resize the form, the listview will not change its points of all the four edge. In the properties window change the anchor property of the listview to “Top, Bottom, Left, Right”, run the form and chec

How to change Theme Dynamically using QueryString in ASP.NET

Introduction About Theme Using theme you can change your page look or design.Themes define the style properties of a web page . Now, let's explore the elements of themes , such as skins, Cascading Style Sheets (CSS), and images. A skin is a file with the .skin extension that contains property settings for individual controls, such as Button, Textbox, or Label. You can either define skins for each control in different skin files or define skins for all the controls in a single file. The skin files with the .skin extension are created inside the subfolder of the App_Themes folder in the Solution Explorer window of a website. <%@ Page Language="C#" AutoEventWireup="true" CodeFile="runtime.aspx.cs" Inherits="runtime" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1&quo

How to use MultiView and View Control in ASP.NET

The MultiView Control The MultiView control is a container for a group of view controls . It allows you to define a group of View controls , where each View control contains child controls . Your application can then render a specific View control based on specific criteria , such as user identity, user preferences, and information passed in a querystring parameter. The MultiView control is also used to create wizard . To allow user to navigate between View controls within a MultiView control, you can add a LinkButton or Button control to each View control. Public properties of the MultiView Class ActiveViewIndex : Obtains or set the index value of the active View control within a MultiView control. EnableTheming : Obtains or sets a value showing whether themes apply to the MultiView control. Views : Obtains the collections of view controls in the MultiView control. Public Methods of the MultiView Class GetActiveView : Obtains the current active View control within a Mul

How to Change file attributes in C# Programming

File attributes are metadata associated with computer files that define system behaviour.  Same as files, folders, volumes and other file system objects may have these attributes. All the operating system have often four attributes i.e. archive, hidden, read-only and system. Windows has more attributes. Read more about File Attributes .  User have to right click on desired file or folder and then open properties, to change the attributes of that file or folder. If one want to change attributes of multiple files then he/she has to either select all the files and then change or change attributes of each file or folder one by one. In programming context we can do this task with a predefined class i.e. FileAttributes which provides all the attributes for files and directories. We can easily change the desired attribute of a file or directory using the above class FileAttributes that is exists in System.IO namespace. Design a new form in windows form application that will look lik

How to use CustomValidator control in ASP.NET

Introduction The CustomValidator control is used to customize and implement data validation as per your requirement. Occasionally, You might need to validate your data in a way that is not possible directly with the help of existing the Validation controls. For example , if you want to find out whether a number is odd or even , you cannot use an existing validation control for doing that because this functionality is not included in any of the Validation controls. To solve this problem , you need a Validation control that can be customized to solve this problem. The CustomValidator control exists within the System.Web.UI.WebControls namespace. The CustomValidator control checks whether or not the input you have given, such as prime, even, or odd number, matches a given condition. Public Properties of the CustomValidator Class: ClientValidationFunction : Obtains or sets the name of the custom client-side script function used for validation. ValidateEmptyText : Obtains or sets s

Example of AutoComplete Type property of TextBox Control in ASP.NET

Obtains or sets a value that indicates the AutoComplete behavior of the TextBox control. Introduction AutoComplete means your textbox control should filled automatically after given some word or letter into your textbox. Suppose you have a email input textbox on your browser screen and this textbox automatically  filled after giving some words or letter. Lets take an 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>     <form id="form1" runat="server">     <div>         <asp:TextBox ID="TextBox1" runat="server" AutoCompleteType="Email" Height="26px" Width="270px"></asp:TextBox>     </div>     </form> </body> </html>

How to make comment box in ASP.NET

Basically CommentBox shows list of data. So we can use repeater control for this types of application.The Basic logic behind of this application is. Feed your user data to database table first Show data from database table using repeater control. Introduction on repeater control The Repeater control is a data bound control that is used to display repeated list of items from the associated data source. It is a single WebControl that allows splitting markup tags across the templates . The Repeater control does not provide support to in-Built layout or styles . Therefore, While working with the repeater control you have to explicitly declare all layout  , formatting , and style. In other words , The Repeater control does not support built-in selection or editing features. Create database Table Make Stored procedure   CREATE PROCEDURE insrtdata AS select * from commentbox RETURN 0 <%@ Page Language="C#" %> <!DOCTYPE html>

Programming techniques and logic in c language

Introduction The tools like algorithm and flow charts help in understanding the problem and analyzing it. Once the problem and the required solution format are clear , the programming is too easy . In order to program the logical structure derived from algorithm or flowchart , one of the programming languages is picked . The selection of the programming language also depends on the nature of the problem. You will see the different programming techniques that are used to solve a problem. The solution of the problem is nothing but to design the program . Before going into the actual design , one should understand the features, merits and demerits of each programming technique . After selecting the technique for programming , the next step is the selection of logic . In general , a program can be written in different ways. The different ways give rise to the logic of the program. One of the programs whose logic is simple and understandable is finally selected for implementatio

How to prevent duplicate child forms in windows forms C#

In my previous post  we have create an MDI container form in which we have opened some individual forms called child forms. Each form contains a property MdiParent that is used to get or set the parent form of a particular form. Form2 obj = new Form2(); obj.MdiParent = this; obj.Show(); As we know, in MDI container application user opens multiple child forms at a time. Most often when user opens a child form, application opens a new instance of the form,  doesn't  matter the form is previously opened or not. This is programmer’s job to check if the same form is previously opened then bring that form to front otherwise create a new instance. To check the instance is null or not we have to write following code in our code behind file of form that will be the child form. private static Form3 instance; public static Form3 GetInstance() { if (instance == null) instance = new Form3 (); return instance; } In above code we have defined a new object of type Form3.

Filter data in datagridview according to combobox in c#

As we have previously studied that datagridview is used for display rows and columns of data in a grid format in windows form. Mostly data are previously defined which are to be shown in datagridview. Sometimes we have to change the data on basis of some conditions. In previous post  we have learnt to bind a datagridview with search option and in else case all the data from database will bind to datagridview in C# language. In this post we will learn to bind datagridview with the selected index changed event of combobox in C#. The selection changed event of combobox occurs when the value of selected index property changes. We are going to change our data of datagridview according to that changed value. Let’s create a student class, which will be used to bind our datagridview, having some properties like below: public class Student { public string Name { get; set; } public int Age { get; set; } public string Address { get; set; } public string Branch { get; set

How to use TextBox control in ASP.NET

Introduction The TextBox control is an input control , which allows you to enter text. The TextBox control exists within the System.Web.UI.WebControls namespace. You can set the style of the TextBox by using the TextMode property . By default , the TextMode property is set to SingleLine to create a single-line HTML . text field but it can also be set to MultiLine for a multiline textbox. You can convert a mode of TextBox control to a Password control, where the text, which the user types is masked with special symbols such as asterisks (*). The display width of a textbox is set with its columns property and if it is a multiline textbox , the display height is set with the Rows property. Public Properties of the TextBox Classes AutoCompleteType : Obtains or sets a value that indicates the AutoComplete behavior of the TextBox control. AutoPostBack : Obtains or sets a value that indicates whether an automatic postback to the server occurs when the TextBox control loses focus

ASP PROGRAM : How to use Wizard Control in ASP.NET

ASP PROGRAM : Introduction The wizard control provides navigation and a User Interface (UI) to collect related data across multiple steps. It also allows you to implement liner or non-linear navigation through the steps such as skipping unnecessary steps or returning to a previously completed step to change some value. The appearance of the wizard control is fully customized by using templates , skins and style settings; for example , you can use the HeaderTemplate , SideBarTemplate, StartNavigationTemplate , FinishNavigationTemplate , and StepNavigationTemplate properties to customized the interface of the Wizard control. Public Properties of the Wizard Class ActiveStep : Obtains the step in the WizardSteps collection , which is currently displayed to the end-user ActiveStepIndex : Obtains or sets the index value of the current WizardStepBase object. CancelButtonImageUrl : Obtains or sets the URL of the image displayed for the cancel button. CancelButtonStyle : Obtains a r

How to Bind Bulleted List using XMLDataSource in ASP.NET

Related Post How to bind Bulleted List control in asp.net How to use BulletedList Control in ASP.NET <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server"> </script> <html xmlns=" http://www.w3.org/1999/xhtml "> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>             <asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="XmlDataSource1" DataTextField="Text" DataValueField="url" DisplayMode="HyperLink">         </asp:BulletedList>         <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/database/adver.xml"></asp:XmlDataSource>         </div>     </form> </body> </html> Output

How to use ImageControl in ASP.NET

Introduction  The Image control is standard Web Server control, which is used to display an image on a Web page. This control exists within the System.Web.UI.WebControl namespace. You set the Uniform resource Locator (URL) of the image with the ImageUrl property of the Image control. The alignment of the image in relation to other elements on the Web page is specified by setting the ImageAlign property. Public properties of the image Class AlternateText : Obtains or sets the alternate text displayed in the image control when the image is not available . Browsers that support the ToolTips featurs display this text as a tooltip. DescriptionUrl : Obtains or sets the location to a detailed description for the image. Enabled : Obtains or sets a value indicating whether the control is enabled. Font : Obtains or sets the font properties for the text associated with the control. GenerateEmptyAlternateText : Obtains or sets a value indicating whether the control generates an alter

How to use TextChanged event in ASP.NET

Note : Event occurs only when the AutoPostBack property of the control is set to true.   Example of TextChanged event of the TextBox when AutoPostBack property is set to true. <%@ Page Language="C#" %> <!DOCTYPE html> <script runat="server">     protected void TextBox2_TextChanged(object sender, EventArgs e)     {         int a = Convert.ToInt32(TextBox1.Text);         int b = Convert.ToInt32(TextBox2.Text);         int c = a + b;         TextBox3.Text = Convert.ToString(c);            } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title> </head> <body>     <form id="form1" runat="server">     <div>            Enter first number:<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>         <br />         Enter Second Number :         <asp

How to use Hyperlink control in ASP.NET

Introduction The HyperLink control is used to create a link to another Web page that can be a page in your Web application. or anywhere else on the World Wide Web (www) . The HyperLink control exists within the System.Web.UI.WebControls namespace. You can specify the location of the linked page by specifying its URL on the current page . You can use text as well as an image in the HyperLink control. Text is specified with the Text Property and image is specified by the ImageUrl property . By default , when you click a Hyperlink control , the Hyperlinked content appears in a new browser window. You can set the Target property to the name of a window or frame , as linked in blow Related Post: How to Bind Hyperlink control in datalist in asp.net Target property Options of the HyperLink class _blank : Displays the hyperlinked content in a new window without frames. _parent : Displays the Hyperlinked content in the immediate frameset parent _self : Displ