Onchange Event In JQuery For Dropdown Example

Onchange Event In JQuery For Dropdown Example asp.net / HTML:

In this post, I am going to discuss the onchange event in jquery for dropdown for the Asp.net text box as well as the HTML textbox. If you think both controls (Asp.net and HTML) are the same then I will say no every time whenever  asp.net page runs it converted into HTML with some page life cycle (PLC) steps. If You take asp.net ControlID="ddlcountry" after page rendering it will be converted into id="ct100_ddlcountry". 

So here we need to take care of these things while calling the asp.net controls in JQuery. Let's have a look.

change Event In JQuery For Dropdown

Jquery Onchange Event with Asp.net DropDown

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        $(document).ready(function () {
            $('#<%=ddlcountry.ClientID%>').change(function () {
                var Country_ID = $('#<%=ddlcountry.ClientID%>').val();

    <form id="form1" runat="server">
            <asp:DropDownList runat="server" ID="ddlcountry">
                <asp:ListItem Value="0">--Select--</asp:ListItem>
                <asp:ListItem Value="1">India</asp:ListItem>
                <asp:ListItem Value="2">US</asp:ListItem>
                <asp:ListItem Value="3">UK</asp:ListItem>


Jquery Onchange Event with HTML DropDown

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        $(document).ready(function () {
            $('#ddlcountry').change(function () {
                var Country_ID = $('#ddlcountry').val();

            <select id="ddlcountry">
                <option value="0">--Select--</option>
                <option value="1">India</option>
                <option value="2">US</option>
                <option value="3">UK</option>

1. Always Call Asp.net Control ID like this $('#<%=ddlcountry.ClientID%>').
2. Call HTML Control ID Like this $('#ddlcountry')

Also Read:

Textbox onchange jquery

I hope you like this "change event in jquery for dropdown". If you have any question feel free to comment below.

Read More

Store procedure in asp.net c# SQL Server

Store procedure in ms sql

In this tutorial I am going to Talk About "Store procedure in asp.net c# SQL Server". A stored procedure (SP) is a precompiled set of T-SQL statements, the basic purpose of which is to group T-SQL statements together to perform a task or set of multiple tasks. It is stored in the data dictionary and can be executed either from the SQL Server Management Studio or from within an application as required.


Stored procedures can execute batches of T-SQL statements, and return multiple result sets as well. It can accept input parameters and can return one or more output parameters to the calling procedure or batch. A stored procedure can call other stored procedures and can also return status information to the calling procedure to indicate whether they succeeded or failed.

Benefits of a Stored Procedure

Modular Programming – After a Stored Procedure is created, it can be invoked multiple times from multiple places from any application. If any modification is needed in the SP, it needs to be done only at one place. It increases code reusability.

Improved Performance – Stored Procedures executes the code faster and reduces the network traffic.

Faster execution – Stored procedures are precompiled i.e; parsed and optimized as soon as they are created and are stored in memory. Thus it executes a lot faster than sending many lines of SQL code from your application to the SQL Server. Doing that requires SQL Server to compile and optimize your SQL code every time it runs.

Reduced network traffic – Sending many lines of SQL code from an application over the network to SQL Server, impacts network performance. This is especially true if the SQL code is lengthy and is accessed frequently in the application. Running the code on the SQL Server (as a Stored Procedure) eliminates the need to send this code over the network. The only network traffic will be the parameters supplied ti invoke the SP and the results of any query. Stored Procedures limit data with WHERE clauses, ensuring that your application sends just the necessary data over the network wire.

Security – Users can execute a stored procedure without needing to execute any of the SQL statements directly. Therefore, a stored procedure can provide advanced database functionality for users who wouldn't normally have access to these tasks, but this functionality is made available in a tightly controlled way. You can grant rights to the stored procedure without granting rights to the underlying objects.

Stored Procedures can be used to make SQL injection attacks more difficult to execute successfully.
Stored Procedures enable you to perform error-handling at the server.

Syntax of a Stored Procedure:

CREATE PROCEDURE procedure_name





Types of Stored Procedures

There are three types of Stored Procedures:

User Defined Stored ProceduresUser Defined stored procedures are created by normal users like us.

SQL Server System Stored Procedures – System stored procedures usually begin with sp_ and most of them live in the Master database. They handle much of what is considered to be the nuts-and-bolts of SQL Server administration, and are written in T-SQL just like user defined SPs. Many vital functions of SQL Server rely on these SPs to remain intact!

Extended Stored Procedures – Extended stored procedures usually begins with xp_ or sp_ and also live in the Master database. They are not written in T-SQL. They are in fact compiled DLLs which open up a world of functionality to the SQL Server environment.

Read More

[Solved] Autocomplete textbox jquery asp.net

Autocomplete textbox jquery:

In this tutorial, I am going to show you "autocomplete textbox jquery asp.net". JQuery autocomplete facility provides auto-complete and the auto-suggest keyword for the textbox input field like google search, there are multiple ways you can go for autocomplete textbox in JQuery.
Here is the example of asp.net c# textbox which will show you how you can implement an autocomplete textbox in Jquery.

Autocomplete textbox jquery,like google search,asp.net
Autocomplete textbox jquery

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="autocomplete.aspx.cs" Inherits="autocomplete" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <%--add these file in head tag--%>
   <script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.8.0.js"></script> 
    <script src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.22/jquery-ui.js"></script> 
   <link rel="Stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.10/themes/redmond/jquery-ui.css" />  

   <script type="text/javascript">
        $(document).ready(function () {
            var availableTags = [
                source: availableTags

    <form id="form1" runat="server">
        <div class="demo">
            <div class="ui-widget">
                <asp:Label ID="Label1" runat="server" Text="Enter Text here"></asp:Label>
                <asp:TextBox ID="tags" runat="server"></asp:TextBox>

Read More

Top 10 Asp.net Web Config Interview Questions

Web config interview questions and answers asp.net

Today, In this tutorial I am going to talk about asp.net web.config file and its uses, we will also talk about the FAQ of web config, which is asked in asp.net interview. As shown by the name "wen.config" it means web configuration. Where we can do custom configuration like URL Rewriting, Authentication and authorization, connection and all. So let's see how it works and the important question which is asked during the interview.

Top 10 Asp.net Ceb Config Interview Questions

Some main work of web.config file

  • Custom error configuration (for 404, 403, other error of application)
  • Database connection configuration.
  • Error handling.
  • Security.
  • Url rewriting.
  • Declaration of variables (key) -- For global use in the application.

Web config interview questions

Q.1) What is a web.config file.
Ans: Web. Config is an application configuration file of asp.net application which is written in XML Format. Every root directory has only one web config file. We can have multiple web config files in our asp.net application there is no restriction to use the web.config file.

Q.2) Does web.config file case-sensitive?
Ans: Yes.

Q.3) What is the format of the web.config file.
Ans: XML Format.

Q.4) Can the ASP.NET project run without a Web.config file?
Ans: Yes we can run.

Q.5) Can we have multiple web.config in one application
Ans: Yes, we can have multiple web config in one application, but one directory can contain only one web config.

Q.6) How you will configure the connection for the database in web config?
Ans: By adding the <connectionstring> </connectionstring> tag, later on we will configure our connection between these tag.

    <add name="mydatabasename" connectionString="Data Source=.;Initial Catalog=list4business;Integrated Security=true; timeout=10000;" />

In the above <connectionStringswe have multiple attributes in <add> tag. let's know about each part on the above connection line.
name is used for the connection name, later with help of this name we can call our connection string.
connectionString is used for the connection with the database (SQL, Oracle). In connectionString we have Data Source, Initial Catalog, Integrated security.

Q.7) Write the syntax of the app setting in the web config.
Ans: In-App setting, we can add values in key-value format and later on we can use it multiple times according to our requirement.

      <add key="registration_email_id" value="[email protected]" />


How to use appsetting in cs page of application.

string email_id = ConfigurationSettings.AppSettings["registration_email_id"];

Q.8) Can we set the startup page on the web.config file.
Ans: We can set a startup page on web config by using some code. First, find the System.webserver in web config and write the following code within <system.webServer</system.webServer>

<defaultDocument enabled="true">
    <add value="index.aspx"/>

In the Above source code index.aspx will be your startup page.

Q.9) How to Use Web. Config customErrors for ASP.NET.
Ans: In asp.net application customErrors support mainly 3 types of modes.

Q.10: How to increase request time out by web config.
Ans: By adding the following code in web config under the<system.web</system.web> 
    <httpRuntime executionTimeout="180" />
Q.11 How to  Enable SSL in the web.config asp.net
Ans: By the following code.

                <clear />
                <rule name="Redirect to https" stopProcessing="true">
                    <match url=".*" />
                        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                    <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />


I hope you like this "Web config interview questions". Please don't forget to comment below. If you found it to be helpful.

Read More