Skip to main content

Posts

Showing posts from March, 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 });             }            

Can we take multiple web.config files in single asp.net application

Yes,  we can take multiple web.config files in the single asp.net application. If we have a single directory then we can add multiple config file with different name. If you want to access xml tag from config file then you can access only web.config file elements. Lets take an simple example of the file. web.config file <configuration>   <appSettings>     <add key="first" value="My first web.config file"/>           </appSettings> </configuration> Default.aspx file     <asp:Label ID="Label1" runat="server" Text="<%$appSettings:first%>"></asp:Label>  Its working fine, but when we take another config file in the application then get the error like file not found error. So, i have a solution of this problem. Follow the mentioned steps to overcome this problem: Step-1 : Add a new directory in the solution(application) Step-2 : Add new web.config file in the new

Button Enable disable when we write some text into TextBox in ASP.NET

I mean to say, we have three controls, two TextBoxes and one Button control. When we run the source code in the browser button is disabled by default. If we want to enable button at run time then we must to input some text in both TextBoxes. For this type of problem we should go for java script. <%@ Page Language="C#" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">     <title></title>     <script>         function change(textb,buttont)         {             var firstt = document.getElementById('<%= TextBox1.ClientID %>');             var secondt = document.getElementById('<%= TextBox2.ClientID %>');             if ((textb.value.length>=1 && firstt.value.length >= 1) && (textb.value.length>=1 && secondt.value.length >= 1))                 document.getElementById(buttont).disabled = false;        

How to create pdf file in windows form c#

If you wan to create pdf file in windows form as well as web application , you must to add iTextSharp.dll file as a reference. In iTextSharp , we have a Document class through which we can create a new document. Also provide PdfWriter class, through which we can create a pdf file in a specified path. Now, you can use Paragraph class for creating text. Now, use this code and Generate pdf file: Document d1 = new Document();             PdfWriter.GetInstance(d1, new FileStream("E:/t1.pdf", FileMode.Create));             d1.Open();             Paragraph p1 = new Paragraph("Hello World");             d1.Add(p1);             d1.Close(); Video cover all such things which is i mentioned in above. Also provide the link where you can download the iTextSharp.dll file and where you will put the mentioned code in function.

How to write something on image in windows form c#

Using Graphics class we can write something on image. Graphics class object invoke drawing objects, like String, Rectangle, oval etc. For DrawString( ) method, we need some parameter like string text, font, point where you want to display string on image. Now copy this code             Image img = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);             var font = new Font("TimesNewRoman", 25, FontStyle.Bold, GraphicsUnit.Pixel);             var graphics = Graphics.FromImage(img);             graphics.DrawString("Hello World! " , font, Brushes.Red, new Point(0, 0));             this.pictureBox1.Image = img; Here First to add the picture box in the form. Now, using the Bitmap class we can pick the resolution parameter of picture box then assign these parameter to Image class instance. Take Font class for making highly visualize text in the image. Use graphics class to Draw the string on the image. Before Drawing must to

Tips for program designing in C language

Now, let us see "What are the tips to design a good program?" Although the program design involves several stages, the following are the few important tips to design a good program: I Tip: Make a program readable. It is a combination of the following: Careful choice of data structure or data type. Careful choice of variable names. Generous use of remarks or comments. Program indentation. General program design II Tip: Stepwise refinement of a solution Break a problem into a sequence of relatively self-contained or independent sub-problems. Follow orderly flow of stepwise refinement. III Tip: Avoid 'goto' statement to jump around, forward and backward, into and out of loops or blocks of statements. The blocks are also called compound statements. The programs using 'goto' are difficult to read and debug. The programs using 'goto' are called unstructured programs. Always hate such unstructured programs.

Coupling in borland C language

Coupling measures the strength of all relationships between functional units. It is the measure of the interdependence of one module to that of another. The program should have low coupling. Low coupling minimize the cause of errors in other modules. The errors in the other modules are caused because of the change in one module. Definition: Coupling can be defined as the degree of interdependence between two or more modules. The reduction in coupling reduces the complexity of the program. While designing a program, make each module as independent as possible eliminating unnecessary relationships. The following figure shows the types of coupling that exists in programming: Types of Coupling: 1. No direct coupling 2. Normal coupling     2.1   Data coupling     2.2   Stamp coupling     2.3   Control coupling 3. Common coupling 4. Content coupling No direct coupling : These are the independent modules of the program. They are not really components of a single

Pointer introduction in C language

Introduction Pointer is one of the important feature available in C language. Almost all the program in the software industry are written only using pointer, But many people think that pointer concept is difficult. The correct understanding and use of pointer is very much required for successful C programming. Pointers are one of the strongest and also one of the most dangerous features(if not used properly) available in C. Due to its important and dangerous feature, the concept of pointer is dealt in detail. Now , let us understand the concept of pointers. Pointer concept  Definition  : The basic data types in C languages are int, float, char , double , and void. Pointer is a special data type which is derived from these basic data types. So, pointer is called derived data type. The pointer takes the values from 0 to 65535 (Memory address) if the size of the RAM is 64K. The pointers are always associated with the following three concepts: Pointer concept Pointer Constants

Linear Search in C language

Searching Before writing the algorithm or program for searching , let us see, “ What is searching? What are the searching techniques?” Definition : More often we will be working with the large amount of data. It may be necessary to determine whether a particular item is present in the large amount of data or not. This process of finding a particular item in the large amount of data is called searching. The two important and simple searching techniques are linear search and binary search. SQL Video Channel : Download all SQL Video Linear search (Sequential search) “What is the linear search?” Definition: Linear search is a simple searching techniques in which we search for a given key item in the list in linear order(Sequential order) i.e. one after the other. The item to be searched is often called key item. The linear search is also called sequential search. For example , if key=10 and the list is 20,10,40,25 after searching we say that key is present . If ke

Code of Image Captcha in windows form c#

Image captcha is used for human verification. Actually some bots machine is used for creating back links to the blog/website. If you want to stop that machine, create human verification captcha. There are two types, first one is string based and another one is numbered based captcha. In this example, i will implement number based captcha. Learn, how to design numbered based captcha. Actually, we will write some randomly generated number on image. After that we compare that number with the text box. Video Contain Full code implementation details: Copy this code and paste in the code file:   int number = 0;         private void createcaptcha()         {             Random r1 = new Random();             number = r1.Next(10, 1000);             Image img = new Bitmap(this.pictureBox1.Width, this.pictureBox1.Height);             var font = new Font("TimesNewRoman", 25, FontStyle.Bold, GraphicsUnit.Pixel);             var graphics = Graphics.FromImage(img);        

How to change Background image as a slider in windows forms application c#

Change background look attractive and different. If you want to change background with image also you want to put image slider in background, read this article carefully. Before put some images in background must to add some images in resource folder. Learn How to add images in resources folder: follow the mentioned path which is given below Expand properties -->Resources-->Add Resource-->Add existing file Now, set the Background image of the form through code file, add line of code before InitializeComponent() method.    public Form1()         {             this.BackgroundImage = Properties.Resources._007;             InitializeComponent();           } Now, Take a timer a control with Tick event also set the timer interval. After every interval image should be change. Now, copy the following code and paste in the code file: Class constructor code:  public Form1()         {             this.BackgroundImage = Properties.Resources.banner;             Initia

edmx with linq query to save and retrieve image to database in windows form c#

In my previous article we have already seen this article( Insert and retrieved ) using ado.net in asp.net, On that time we  used nvarchar(size) datatype to store the image in database. Today, i am talking about image data type. Actually image data type store image in binary format. Also i will use edmx file or you can say entity framework to store and retrieve image from database table. First to create a database table in sql server management studio. Now, your table script look like: USE [ht] GO /****** Object:  Table [dbo].[tblPicture]    Script Date: 4/3/2015 6:28:16 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE TABLE [dbo].[tblPicture]( [id] [int] IDENTITY(1,1) NOT NULL, [pic] [image] NULL,  CONSTRAINT [PK_tblPicture] PRIMARY KEY CLUSTERED ( [id] ASC )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] ) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY] GO Now, s

How to bind label and text box control using edmx file in windows form c#

In previous article we have already learn about bind label or text box using ado.net . Today, i will discuss about edmx file. If you want to bind label or text box in windows form, edmx file is the best solution for this type of problem. There are following steps to bind the label or text box: I am giving you a whole code video for user friendly:  First to add some label and text boxes in the form Like:  Now, add edmx file in the solution Now, copy this code and paste in the button click event handler block.  private void button1_Click(object sender, EventArgs e)         {             int id = Convert.ToInt32(idtxt.Text);             Student_DBEntities dc = new Student_DBEntities();             var getrecord = dc.Student_record.Where(a => a.Id == id).SingleOrDefault();             Studentidtxt.Text = getrecord.Student_Id;             studentnametxt.Text = getrecord.Student_Name;             fathernametxt.Text = getrecord.Father_Name;            

How to bind ComboBox using edmx in windows form c#

Introduction In my previous article i have already explained about bind combo box with entity framework using code first approach . also bind combo box with ado.net. Now, today i am discussing about edmx file. Before bind the combo box with edmx file , first to add edmx file in the solution or you can say project. Now, add a combo box in the form. Copy the following code and paste in class constructor after  InitializeComponent(); method.  Student_DBEntities dc = new Student_DBEntities();             var item = dc.Student_record;             comboBox1.DataSource = item.ToList();             comboBox1.DisplayMember = "Student_Name"; Now, Code generate the following output: The following video cover all such types of things which is mentioned in the article, i am giving you this video for better understanding: Here, Student_DBEntities is a context class through which we can access or manipulate database record. (Check the context file in your solution).

Difference between malloc( ) and calloc() in C language

In c language article we will see the difference between malloc() and calloc(). Both are the functions in c language. See the table which is mentioned below: Malloc() Calloc() The Syntax of malloc() is : Ptr = (data_type *) malloc(size); The required number of bytes to be allocated is specified as argument i.e. size un bytes. The Syntax of calloc() is : Ptr = (data_type*)calloc(n,size); Takes two arguments: n is number of blocks to be allocated, size is number of bytes to be allocated for each block. Allocates a block of memory of size bytes. Allocates multiple blocks of memory, each block with the same size. Allocated space will not be initialized Each byte of allocated space is initialized to zero. Since no initialization takes place, time efficiency is higher than calloc() Calloc() is slightly more computationally expensive because of zero filling but, occasionally, more convenient than malloc().

Advantages and Disadvantages of pointers in C language

By this time, you might have understood the concepts of  C pointers and if any problem is given, you should be in a position to solve. After understanding the full concepts of pointers, we should be in a position to answer the question " What are the advantages and disadvantages of pointers?" Advantages More than one value can be returned using pointer concept (pass by reference). Very compact code can be written using pointers. Data accessing is much faster when compared to arrays. Using pointers, we can access byte or word locations and the CPU register directly. The pointers in C are mainly useful in processing of non-primitive data structures such as arrays, linked list etc. Disadvantages Un-initialized pointers or pointers containing invalid addresses can cause system crash. They are likely to be used incorrectly causing bugs that are very difficult to identify and rectify. They are confusing and difficult to understand in the beginning and if they are