Powered by Blogger.

Working with enterprise library for data access in asp.net Part-3

To work with enterprise library you have to download required from this URL. Here we will use Enterprise Library 5.0 version. We need to give reference in Bin folder to the following dlls: Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.EnterpriseLibrary.Configuration.Design.dll

Asp.Net MVC4 sample application

we will make a sample application using Asp.Net MVC4. Open Visual Studio 2010, then go to File -> New Project. This will open the New Project dialog box. From there make sure .Net Framework 4 is selected. Then select the Visual C# -> Web templates list. From the web template lists, Select ASP.NET MVC 4 Web Application and give a name.

Object Oriented Programming (OOP) concepts in .Net

Mainly there are 3 things in OOPs concept. 1- Inheritance 2- Abstraction 3- Polimorphism Inheritance is one of the key feature of oops concept and C# supports inheritance. Inheritance is a process of deriving the new class from already existing class. It allows you to reuse existing code.

Tutorial on MVVM with WPF

MVVM is nothing but Model view and viewModel.This is the best architecture for WPF. VIEW: A View is defined in XAML and should not have any logic in the code-behind. It binds to the view-model by only using data binding. The View contains the visual controls that will be shown to the user.This is the UI.

WCF tutorial and example in C#.Net

We will discuss how to create a WCF service and how we can consume the WCF service. Open Visual Studio 2010, then go to File -> New -> Project. Then from the New Project dialog box, From the Installed Templates Select WCF from the left hand site, And then Choose WCF Service Library and Give a proper name and Click on OK.

Saturday, October 28, 2017

How to to show or hide textbox based on checkbox using jQuery in asp.net?

In this post we will discuss how we can show or hide texbox based on checkbox using jQuery in asp.net. Here we have used a textbox, one checkbox. On checkbox checked or unchecked we are going to hide a textbox.

Also you can read:
- Date validation using JavaScript

- Split javascript string

- How to validate user input for mobile number using Regular Expression in Javascript?

Below is the full code:



<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#isCheckBox").on("click", function () {
                if (document.getElementById('isCheckBox').checked) {
                    $("#txtMyTextBox").show();
                } else {
                    $("#txtMyTextBox").hide();
                }
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="checkbox" id="isCheckBox"/> I Agree<br />
            <input type="text" id="txtMyTextBox"/><br />           
        </div>

    </div>

On Check box checked or unchecked the textbox will be show or hidden.

show hide textbox using jquery checkbox

Hope this will be helpful.

How to check if checkbox is checked using jQuery in Asp.Net?

In this post we will discuss how we can check if checkbox is checked or not using jQuery in asp.net.

For this particular example, I have added an input check box and a button, and on the button click we are going to display if the checkbox is checked or not.

Also you can read:
- How to remove particular element from an array using JavaScript in asp.net?

- Data Binding and Graphics in WPF

- WCF tutorial and example in C#.Net



Below is the full code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnClick").on("click", function () {
                if (document.getElementById('isCheckBox').checked) {
                    alert('Checked')
                } else {
                    alert('Unchecked')
                }
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="checkbox" id="isCheckBox"/> I Agree<br />
            <input type="button" id="btnClick" value="Click Here" /><br />
        </div>
    </div>

Once you click on the button, you can see it will display checked if the checkbox is checked.

Check if checkbox is checked using jQuery

How to remove particular element from an array using JavaScript in asp.net?

Here we will discuss how we can remove particular element from an array using JavaScript in asp.net. We can use the splice function to remove the element.

Also you can check out:
- How to get substring from string using jQuery in asp.net?

- How to open hyperlink in new tab using jQuery or JavaScript?

- How to validate user input for mobile number using Regular Expression in Javascript?

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var array = [1, 2, 3];
                var index = array.indexOf(2);
                if (index > -1) {
                    array.splice(index, 1);
                }
                alert(array.length);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Remove Element From Array" /><br />
        </div>
    </div>

Once you will click on the button, it will show the length like below:

remove particular element from array using JavaScript

Hope this will be helpful.

How to get substring from string using jQuery in asp.net?

Here we will discuss how we can retrieve sub string from string using jQuery in asp.net. We will do this inside an asp.net.

Here we can extract a substring out of string using substring() JavaScript method. Here we will do on a button click.

substring() method will take the start position and number of characters. If the second parameter is not specified then it will return till end.

Also you can read:
- How to get current page URL using jQuery in asp.net?

- Cross-page posting in Asp.Net

- Bind dropdownlist from enum in Asp.Net

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var mainString = "This is our main string.";
                var subString = mainString.substring(5, 16);
                alert(subString);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Get sub string" /><br />
        </div>

    </div>

Once you click on the button, you can see the result like below:



get substring from string using jQuery

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var mainString = "This is our main string.";
                var subString = mainString.substring(5);
                alert(subString);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Get sub string" /><br />
        </div>

    </div>

Onc you click on the button, you can see the result like below:

asp.net get substring from string using jQuery

Hope this will be helpful.

How to find number of characters in a string using jQuery in asp.net?

Here we will discuss how to find number of characters in a string using jQuery in asp.net.

Here we will do this exercise inside an asp.net application.

Also you can read about:
- Array and ArrayList in C#.Net

- switch statement in C#.Net

- Add property to class in C#.Net

Below is the jQuery and JavaScript code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetString").on("click", function () {
                var mainString = "This is our main string.";
                alert(mainString.length);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetString" value="Get Characters in string" /><br />
        </div>

    </div>

It will display the results like below:

jQuery find number of characters in string

What is the difference between String and string in C#.Net?

Here we will see what is the difference between String and string in C#.Net.

Actually there is no difference between String and string.

Also read my previous posts: How to call non static method inside main in C#.Net console application?, What are the differences between Hashtable and Dictionary in C#.Net? and also you can check How to split a string by another string in C#.Net?

string is an alias for System.String in C#.Net. Both of them are compiled to System.String.

But we need to just follow a guideline.

If you are referring to a Class then you should use String. And if you are referencing to an object then we should use string.

Example:
String.Format ("Hello {0}!", name);

string name = "Bijay";

To use String in a class we need to write the using System; statement.

And also string is a reserved keyword, so we can not use as variable name.

How to get current page URL using jQuery in asp.net?

Here we will discuss how we can get current page URL using jQuery in asp.net. Recently we got one requirement to retrieve the current page using jQuery in asp.net.

To get started with asp.net, let us create a web site first.

Also you can see my previous posts on: Difference between asp.net and asp.net core, also read Clear textboxes inside a form in C#.Net, Get all time zones in C#.Net and Convert ArrayList to String using C#.Net.

Open Visual Studio 2015 -> File -> New -> Web Site...
Then in the New Web Site dialog box, then choose ASP.NET Web Forms Site template
from Templates -> Visual C#.

jQuery get page URL in asp.net

Then in the Default.aspx page, write the below code. On the button click it will display the current page URL.

Below is the jQuery code.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#btnGetURL").on("click", function () {
                var pageURL = $(location).attr("href");
                alert(pageURL);
            });
        });
    </script>
    <br />
    <div class="row">
        <div class="col-md-4">
            <input type="button" id="btnGetURL" value="Get Current Page URL" /><br />
        </div>

    </div>

Once you click on the button, you can see the current page URL like below:

Asp.Net get page URL using jQuery