Pages

Ads 468x60px

For New Update Use this Link http://dotnethubs.blogspot.in/ Offer for you

.

Monday 21 October 2013

What are the core components of .NET framework

What are the core components of .NET framework

Categories :- Benefits of net frameworkHR interview question and answer , 1-year-exp-asp.net interview question and answer , Interview questions and answers for 2 years , C# interview Question And Answer

 The Two Components of .NET Framework are
 1) Common Language Run time [CLR]
2)  .Net Framework class Library

 Other key components of .NET Framework:

NET Framework Class Library

  3)   Dynamic Language Runtimes (DLR)
   4 ) Application Domains
   5)  Runtime Host
   6)  Common Type System
   7)  Metadata and Self-Describing Components
    8) Cross-Language Interoperability
    9) NET Framework Security
    10) Profiling
    Side-by-Side Execution

Briefly describe MSIL

.Net Framework is shipped with compilers of all programming languages to develop programs. There are separate compilers for the visual basic,C#, and visual c++ programming languages in .Net Framework.Each .Net compiler produces code after compiling the source code. The intermediate code is common for all languages and is understandable only to .NET environment. This intermediate is know as MSIL.

MSIL file is executable file that can transferred various machines. Therefore, it is said that MSIL file are portable to nay machine.

Monday 14 October 2013

What are the benefits of net framework

What are the benefits of net framework
Categories :- 

.Net framework offers many benefits to application developers.some of this benefits are as follow :

 1) Consistent programming model :- 
 Dot net framework provide consistent object oriented  programming model across various language.You can use the model  to create a program s for performing different task, such as connecting to and retrieving data from database and reading from and writing to files.

2) Language interoperability :- 
 Language interoperability is a feature that enables a piece of code written in one language to be used in another  language.This facilities the reuse of code and therefore improves the efficiency of the development process.

3) Automatic management of resources :-
 While developing .NET application. You may use various resources, such as files, memory, and database connections. with .NET Framework, you do not need to manually free these resources when they are no longer required

4) Easy of deployment :- 
 .NET Framework makes the deployment of application easier. To install an application that is not based on .NET Framework, you need to copy it and its components on target computers. However, with .NET Framework, you can quickly install or deploy the application such that installation of new application or components does not affect the existing  application.

5) HTML code and source code is separate so modification is essay .

6) Asp.net Framework is language independent.


Saturday 12 October 2013

How to get xml data into grid view in asp.net

How to get xml data into grid view
Introduction :- In this article i have explain how to show XML file data in asp.net grid-view .

Description :- In  my previous post i have explained How to Generating XML file From MySQL database 
Create and read XML file in asp.net , Read data from XML file in asp.net , now i have explain how to show XML file data in grid view  using   asp.net

Step 1 :- Create a new asp.net web site.
Step 2:- Add a new page in your project and give the name to the page gridxml.aspx..
Step 3 :- Add  one xml file and write something like this which you want to show on gridview page of asp.net as show below.

Note  - This is a Employees.xml file already exist in your project.


<?xml version="1.0" standalone="yes"?>
<Employees>
  <Employee>
    <EmployeeID>Chitranjan</EmployeeID>
    <CompanyName>abc informatics</CompanyName>
    <ContactName>chintu </ContactName>
    <ContactTitle>Developer</ContactTitle>
    <Address>ganraj</Address>
    <City>Indore</City>
    <PostalCode>452001</PostalCode>
    <Country>India</Country>
    <Phone>00000000</Phone>
    <Fax>4545499</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Aman</EmployeeID>
    <CompanyName>Y N Info</CompanyName>
    <ContactName>Aman</ContactName>
    <ContactTitle>Artiest</ContactTitle>
    <Address>Boriwali east</Address>
    <City>Pune</City>
    <PostalCode>3436</PostalCode>
    <Country>India</Country>
    <Phone>9549544345</Phone>
    <Fax>559935</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Rahul</EmployeeID>
    <CompanyName>Gold Main</CompanyName>
    <ContactName>Hot</ContactName>
    <ContactTitle>Designer</ContactTitle>
    <Address>dfdf</Address>
    <City>bBombay</City>
    <PostalCode>5434546</PostalCode>
    <Country>India</Country>
    <Phone>54545</Phone>
  </Employee>
  <Employee>
    <EmployeeID>Ronak</EmployeeID>
    <CompanyName>Yeswant Niwas</CompanyName>
    <ContactName>Golo</ContactName>
    <ContactTitle>Producer</ContactTitle>
    <Address>345 Alock Nagar</Address>
    <City>Bhopal</City>
    <PostalCode>554677</PostalCode>
    <Country>India</Country>
    <Phone>5656</Phone>
    <Fax>0909ASD</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Ravi</EmployeeID>
    <CompanyName>DFF</CompanyName>
    <ContactName>LJ</ContactName>
    <ContactTitle>PPOIU</ContactTitle>
    <Address>79879 JKJK</Address>
    <City>ABC</City>
    <PostalCode>6656DF</PostalCode>
    <Country>RFF</Country>
    <Phone>54554FGGG</Phone>
    <Fax>GGG555</Fax>
  </Employee>
  <Employee>
    <EmployeeID>JJ8</EmployeeID>
    <CompanyName>HJKGJ8</CompanyName>
    <ContactName>GGH55</ContactName>
    <ContactTitle>New Dehli</ContactTitle>
    <Address>Rambag</Address>
    <City>ASD</City>
    <PostalCode>87GG</PostalCode>
    <Country>India</Country>
    <Phone>7667654</Phone>
    <Fax>FGH45</Fax>
  </Employee>
  <Employee>
    <EmployeeID>Sumit</EmployeeID>
    <CompanyName>Sumo tech</CompanyName>
    <ContactName>Sumo</ContactName>
    <ContactTitle>Manager</ContactTitle>
    <Address>656 FFH</Address>
    <City>Strasbourg</City>
    <PostalCode>8788</PostalCode>
    <Country>Noida</Country>
    <Phone>665-778-545</Phone>
    <Fax>545.54.55</Fax>
  </Employee>
 
</Employees>

 Step 4 :- open the gridxml.aspx file and write the code as show below.



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class CS : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            this.BindGrid();
        }
    }

    private void BindGrid()
    {
        using (DataSet ds = new DataSet())
        {
            ds.ReadXml(Server.MapPath("~/Employees.xml"));
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }

    protected void OnPageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        this.BindGrid();
    }
}

Note -: Source code also available in vb.net

Download sample code attached



Sunday 6 October 2013

Generating Xml file From Mysql database

Generating XML FILE From MySQL database
Introduction :- In this article i have explain how to  generate  XML  File   from mysql database in asp.net .

Description :- In my previous article i have explain Crete and read XML file in asp.net   and  read data from XML file in asp.net . Now i am explain how to generate  XML file in  asp.net.

Friday 20 September 2013

How i can run apk file on emulator

How i can run apk file on emulator

 Categories : - Call asp.net web service from android application

Introduction :- In this article i am explain how to run any .apk file using android emulator.

Description : - In my previous article  i have explained call asp.net web service from android application   Now i am explain how to run .apk through emulator

Step 1  Fist Check jdk is installed  i you system other wise instal the jdk
Step 2  Set the  Environment Variable like this for windows 7
Write click on my computer and go to property -> popup is open and click on Advanced   System Setting ->Advanced->  Environment Varibles
and set path link this image



Note-> Click new then open this popup  and enter variable name and variable values and click ok

Step 3  open eclipse and run any project through emulator your emulator is run properly

Note -> If you have no android project then create a new android application and run the android application using emulator

Step 4  Keep your .apk file within folder of your android sdk\platform-tools

Step 5 - Open cmd prompt and go tto your  sdk\platform-tools folder
 and type the command on cmd

adb install your apk file name

GUI as shown below


You get success message if you .apk is install properly using command prompt

Step 6 -  Check you Apk on you emulator is show properly and click on akp icon of your app it's run properly

Wednesday 28 August 2013

How To Create A JSON Web Service In ASP.NET

How To Create A JSON Web Service In ASP.NET
Categories : -  How to create Ajax enable wcf web service in asp.net

Introduction : - 

 .ASP.NET makes it easy to create web services but they usually return XML. Like many web developers I now prefer JSON. This article and sample code will show you how to get your web service to return data in the JSON format.

Description : -

  For fetch the data from MySQL database using web service in asp.net json format  step as shown below.

 Step :- 1 Create a new web site 
Step : -2 Write click on website and add new web service 
Step : -3 Write a code on WebService.cs file

as shown below



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using MySql.Data.MySqlClient;
using System.Data;
using System.Web.Script.Serialization;
/// <summary>
/// Summary description for WebService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }

     [WebMethod(Description = "Gets All Records.")]

       [ScriptMethod(ResponseFormat = ResponseFormat.Json)]

      public string GetAllRecords() {

          MySqlConnection objConnection = new MySqlConnection("server=localhost;User Id=root;database=databaseName;Pooling=false;Connect Timeout=10;Allow User Variables=True;");

          MySqlCommand objCommand = new MySqlCommand("SELECT * FROM info_tab  ORDER BY id", objConnection);

          DataSet objDataSet = new DataSet();

          MySqlDataAdapter objDataAdapter = new MySqlDataAdapter(objCommand);

           objDataAdapter.Fill(objDataSet, "reading");

           objConnection.Close();
             // Create a multidimensional jagged array
           string[][] JaggedArray = new string[objDataSet.Tables[0].Rows.Count][];

           int i = 0;

          foreach (DataRow rs in objDataSet.Tables[0].Rows)

          {

               JaggedArray[i] = new string[] { rs["user_id"].ToString(), rs["First_Name"].ToString(), rs["Last_Name"].ToString() };

               i = i + 1;

           }

             // Return JSON data

           JavaScriptSerializer js = new JavaScriptSerializer();

          string strJSON = js.Serialize(JaggedArray);

          return strJSON;

       }  

}
 
For Connect to my sql  use the Connector .MySql Connector Download Link is Click

Run your service and seen output like this


Click on  GetAlRecords




 Again Click on Invoke Button and output as shown below


Note : - In Connection String i am not use a password If you define a password at the time of installation of MySQL database then use password=y our password; in connection string

Friday 23 August 2013

Creating Ajax Enabled WCF Service in asp.net

Creating Ajax Enabled WCF Service in asp.net
Categories :- Introduction of WCF service , Advantages and Disadvantages of WCf  Service , Difference betweenWCF service and asp.net service

Introduction :- 

In my previous article i have explain to create restful wcf service api using post step by step .and i have also explained another example for create basic  wcf service step by step in asp.net. In this article, I will explain how to create an AJAX-enabled WCF Service and how to consume it using client-side script in an ASP.NET page. I have kept the example quiet simple so in order to keep our focus on creating and consuming AJAX Enabled WCF Services.

Description :-

AJAX-enabled WCF Service is a service that can be consumed using an AJAX client-side script.
I am using visual stdio 2010 for create a ajax enable wcf service in asp.net.This is very easy for create wcf enable service in asp.net.Follow the step for create a ajax enable web service in asp.net as shown below

Step 1 :-  Open Visual Studio 2010.    Go to File->New->WebSite     Select ASP.NET Empty WebSite

Step 2 : - Go to Solution Explorer and right-click.

    Select Add->New Item ,  Select WebForm ,     Default.aspx page open

Step 3 : -Define WCF Service :
 Go to Solution Explorer and right-click.
    Select Add->New Item ,  Select AJAX Enabled WCF Service ,  Define the Namespace

Step 4 :- Open Default.aspx page and click in [Design option].

 Drag and drop Scriptmanager Control  on the default.aspx web form. Image of form as shown below



Step 6 : -In [design] page right-click in scriptmanager control
Select Properties option
Define Services like this

Click the add option and select Service path like this

you can check this service on click on soure default.aspx design page


<asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="ajax.svc" />
            </Services>
        </asp:ScriptManager>

Step7 : - You have already select AJAX Enabled WCF Service in your app_code folder .
select ajax.cs webservice and double click on code behind and write the following




  [ServiceContract(Namespace = "GreetNM")]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ajax
{
    // To use HTTP GET, add [WebGet] attribute. (Default ResponseFormat is WebMessageFormat.Json)
    // To create an operation that returns XML,
    //     add [WebGet(ResponseFormat=WebMessageFormat.Xml)],
    //     and include the following line in the operation body:
    //         WebOperationContext.Current.OutgoingResponse.ContentType = "text/xml";
    [OperationContract]
    public void DoWork()
    {
        // Add your operation implementation here
        return;
    }
    [OperationContract]
    public string GetUser(string user)
    {
        return "Hello="+user;
    }
  
}


Here  GetUser is  method called GreetUser(string uname) which takes a username and returns a string with the “Hello” greeting appended to the user name. Decorate the method with the ‘OperationContractAttribute’ to indicate that the method is a part of the contract.

step 8 :-
Now add a Html Button, an HTML Input box and <Div> to the Deafult.aspx page.After renaming the controls and adding the onClick event of the button, the markup will appear similar to the following and image as shown above as step number 6




  <div id="ajax_wcf" title="getuser">
  
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="ajax.svc" />
            </Services>
        </asp:ScriptManager>
    <input type="button" id="ajax_wcf" onclick="return ajx_wcf_call()" value="Submit" />
    <input type="text" id="txtnm" />
    </div>

Java Script code :

Step 7 : Now go to Default.aspx page and select Design option.

    Click in the input Button
    Define Java Script code for the on click event

Code :


<script language="javascript" type="text/javascript">
        function ajx_wcf_call() {
            try {
                var greeto = new GreetNM.ajax();
                greeto.GetUser($get("txtnm").value, OnGeetingComplet, OnError);

            } catch (Error) {
            alert("Error");
        }
        }
  
    function OnGeetingComplet(result)
    {
        $get("txtnm").value = result;
        alert(result);
    }

    function OnError(result) {
        alert(result.get_message());
    }
  
    </script>

Compete code as shown below


  <html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        function ajx_wcf_call() {
            try {
                var greeto = new GreetNM.ajax();
                greeto.GetUser($get("txtnm").value, OnGeetingComplet, OnError);

            } catch (Error) {
            alert("Error");
        }
        }
  
    function OnGeetingComplet(result)
    {
        $get("txtnm").value = result;
        alert(result);
    }

    function OnError(result) {
        alert(result.get_message());
    }
  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="ajax_wcf" title="getuser">
  
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            <Services>
                <asp:ServiceReference Path="ajax.svc" />
            </Services>
        </asp:ScriptManager>
    <input type="button" id="ajax_wcf" onclick="return ajx_wcf_call()" value="Submit" />
    <input type="text" id="txtnm" />
    </div>
    </form>
</body>
</html>

The result as for enter the value in text box and click on button




Download sample code attached


Wednesday 14 August 2013

Could not find file exception in asp.net fileupload

Categories : - Create and read XML file in asp.net  , Interview question and answer , Regular expression image validation , Regular expression text box validate for numeric value onlyCould not find file exception in asp.net fileupload

Introduction :-

In this article i am explain how to avoid error file cloud not find when upload any image in folder using asp.net web form .

Error As shown below


Friday 9 August 2013

GridView Paging Not Displaying Data After Switching Page

GridView Paging Not Displaying Data After Switching Page
Categories : - The GridView 'GridView1' fired event PageIndexChanging which wasn't handled

Introduction : - 

In this article i am explaining how i can show GridView Paging Not Displaying Data After Switching Page. In my previous article i have explained Java script for gridview in edit mode , Gridview rowcommand object reference not set to an instance of object

Description : -

I am having a bit of trouble with Paging within a GridView grid I have set up. I have added the paging but whenever I click on the next page or the last page buttons, the page refreshes and displays blank
So Bind the  Gridview as show below




  protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BingGridViewData();//Call bind gridview function
    }


Create a new asp.net web site and add new page . Darg and drop gridview on page . and write this function on code behind of asp.net web page  as shown  below



protected void BingGridViewData()
    {
        _objcon = DonetionConnectionDB.GetConnection();
        DataTable dt = new DataTable();
        string query = "SELECT * FROM causes_tab order by ID DESC";
        MySqlDataAdapter _objda = new MySqlDataAdapter(query, _objcon);
        _objda.SelectCommand.CommandType = CommandType.Text;
    
        _objda.Fill(dt);
        GridView1.DataSource = dt;
        GridView1.DataBind();
        _objcon.Close();
    }



The gridview 'gridview1' fired event pageindexchanging which wasn't handled. c#

The gridview 'gridview1' fired event pageindexchanging which wasn't handled. Solution
Categories :-  Java script validation for Grid View in edit mode , Javascript validation for Gridview footer textbox  , Gridview RowCommand object reference not set to an instance of an object , onclick checkbox select data from gridview asp.net

Introduction  :-

In my previous article I have explained Gridview rowcommand object reference not set to an instance of object.  Now  i have  face this problem when i change the gridview AllowPaging="True" PageSize="1" .The Error message as shown below








 Description : -

Now i have a solution for this problem .
Select the Gridviw and click on PageIndexChanging Event of the Gridview and write a one line code as shown below



protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView1.PageIndex = e.NewPageIndex;
        BingGridViewData();// GridView Paging Not Displaying Data After Switching Page
    }

Fired this event on code behind of the page and error is solved

Saturday 3 August 2013

Regular expression validator for image file extension

Regular expression image file extension

Introduction :- 
In this article i have explained how to validate image using Regular Expression Validator  in  asp.net  before upload in data base or image fonder.In my previous article  i have explained  Different Validation Control in asp.net Like this :- How to allow numeric values into textbox , How to upload multiple photo using asp.net , Asp.net Control With Example , Jquery form validation in asp.net , JavaScript validation for grid view footer textbox , JavaScript validation for grid view in edit mode

 Description :- 

 In this Post I have created a new  project and add use a Regular Expression Validator in asp.net as show below

step 1 -    Create a  new project .
Step 2 -   Write Click on project explorer and add a new form .
Step 3 -   Drag and drop a RegularExpressionValidator and file upload control on the page.
Step 4 -   Drap and drop a  button on the web  page for save the image on click button in the image folder.
Step 5-    Write Click and add new folder in your project.

Now set the property for validate the image using RegularExpressionValidator  as show below

Control to validate =FileUploade
Text = Invalid image icon
 ValidationExperssion  =^.*\.((j|J)(p|P)(e|E)?(g|G)|(g|G)(i|I)(f|F)|(p|P)(n|N)(g|G))$"

 Complete Code as show below


<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  
        <asp:FileUpload ID="File1" runat="server" />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Upload" />
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
            ControlToValidate="File1" ForeColor="Red"
            ValidationExpression="^.*\.((j|J)(p|P)(e|E)?(g|G)|(g|G)(i|I)(f|F)|(p|P)(n|N)(g|G))$">Invalide file !</asp:RegularExpressionValidator>
  
    </div>
    </form>
</body>
</html>


Output image as show below




Download sample code attached







Monday 29 July 2013

Latest asp.net interview questions and answers for experienced

Latest asp.net interview questions and answers for experienced
Introduction : -

I  have Collection new asp.net interview question and answer for experience and fresher .This is very important asp.net interview question with answer.
Every interviewer firstly ask 

1 . Tell me about Your Self ?

Ans  Good morning sir/madam.This is Chitranjan Singh Rathore My educational qualification are: I have completed my 10th standard in 2002 from  Little flower school and also 12th standard in 2004. I have completed my graduation in 2007 from Holkar science college. I have completed my post graduation in 2010 from Medicaps Colloege indore .
For More Click Here

 
2 . What is asp.net ?

Ans  Dot Net is a Framework technology, that means which is integrated with multiple technologies like windows, web, web services, etc.It is Use to develop web based, windows based application.
For More Click Here

3. Difference Between Form authentication and windows authentication ?

For Get the answer- Form authentication and windows authentication

4 . What is authentication and authorization in asp.net ?

Answer . This is very important question .every technical interview round ask this question
               authentication and authorization in asp.net

5.  What is web form ,windows form and client server architecture ?

Ans  - This is very important and interesting question.Now we will talk about(web form and windows form)

Web from :-

1 ) As we know web from use browser presentation(asp.net form has no exception )
2 ) ASP.NET Form inherits Page class (contained in System.Web.UI namespace).
3 ) Web Forms to create Web-based applications that display in a Web browser.
 4 ) Webapplications run on webservers (usually IIS)

Windows From : -

1 ) Window form has own presentation .
2 ) A Form of Windows Forms inherits Form class (contained in System.Windows.Forms namespace).
3 ) Windows Forms to create rich applications that install and run locally on a machine.
4 ) Windows forms are used in desktop based applications which heavily rely on the GDI.

Friday 26 July 2013

How to upload multiple photos using asp.net

How to upload multiple photos using asp.net
Introduction :- 

In my previous  article i have explain the Ajax-asyncfileupload-control-example in asp.net. Now in this article we will upload multiple image using single file upload control in asp.net.

Description :- 

In this Article we take on file upload control and on button on asp.net web from.This is very important article for upload multiple image in database and folder .now we upload the multiple images in a folder some  easy process

Step 1 - Create a asp.net web project and add new from like this
Open visual stdio go to File->new ->Project  and write the name of the project

Step 2 - Write click on solution explorer and add new item ->select new web form->write the name of form

step 3 -  Drag and drop the file upload control on the form
Step 4 - Drag and drop the  asp.net Button on the form
Step 5 - Drag and drop one label on the form for count how many image you have select
Step 6 - Write click on Project (Solution Explorer) and add new folder and give the name to the folder is image

Note -: Write multiple="true" for select multiple file or  image using file upload control of asp.net
Note - use this namespace    using System.IO;

Complete Source Code as shown below

<asp:FileUpload runat="server" ID="UploadImages" multiple="true"/>
    <asp:Button runat="server" ID="uploadedFile" Text="Upload" OnClick="uploadFile_Click" />
    <asp:Label ID="listofuploadedfiles" runat="server" />



double Click on asp.net button control or write click on from and select  View Code .Go to code Behind File and write a code for upload a images in folder.

Code as shown below


      HttpFileCollection fileCollection = Request.Files;
        for (int i = 0; i < fileCollection.Count; i++)
        {
        HttpPostedFile uploadfile = fileCollection[i];
        string fileName = Path.GetFileName(uploadfile.FileName);
        if (uploadfile.ContentLength > 0)
        {
        uploadfile.SaveAs(Server.MapPath("~/image/slider/") + fileName);
      
        listofuploadedfiles.Text += String.Format("{0}<br />",uploadfile.FileName);
    }
    }



Tuesday 23 July 2013

How to allow only Numeric values into a textbox

How to allow only Numeric values into a textbox
Introduction :-

In my previous article i have explained how i can use validation control in asp.net.In this article I am explain how i can allow online integer values for text box using regular expression in asp.net.

Description : -
In my Previous article i have explained how to validated form using jquery in asp.net.And i have Provided Full Description with example for  each and every  control in asp.net. Name of Controls are

RequiredFieldValidation,RangeValidator,RegularExpressionValidator,CompareValidator,CustomValidator,
CustomValidator

In this article i have explain how to validate textbox using regular expression allow only integer values

Process :-
1 : - Create a new project in asp.net and add new from and drag and drop a text box and provide the id to the textbox.In this article the id of text box is txt_priority  .
2 : - Drag and drop the Regular Expression validator on the form and set the property as show below
ID =RegularExpressionValidator1
ControtoValidate= txt_priority   [this is textbox id]
ErrorMessage=Please enter numbers only
ForColor=Red
ValidationExpression=\d+

complete example as show below


<asp:RegularExpressionValidator id="RegularExpressionValidator1"
                   ControlToValidate="txt_priority"
                   ValidationExpression="\d+"
                   Display="Static"
                   EnableClientScript="true"
                   ErrorMessage="Please enter numbers only"
                   runat="server" ForeColor="Red"/>


Wednesday 17 July 2013

How to call asp.net web service from android application

create simple drop down menu using jquery
Introduction : -

 In this  article i am explaining how to call the asp.net  asmx web service .This is very nice article for call the asmx web  service for android application.
Setp 1 ->  Open visual studio and create a new project like this

File->new->Project
And write the name of project and click ok

Step 2  -> Write click on project  add ->add new item
select  web service and click ok and write the code as shown below on our webservice.asmx



using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;


[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

public class WebService : System.Web.Services.WebService {

    public WebService () {

        //Uncomment the following line if using designed components
        //InitializeComponent();
    }

  

    [WebMethod]
    public int Add(int a, int b)
    {
        return a + b;
    }

  
  
}

Step 3 -> Run our web service and check the output is proper or not  like this
Click on Add


Enter Values  a=10 and b=10

Then Click on Invoke and output as shown below

 
Start Android Applcation : -

step 1 -> Doble Click on eclipse IDE and  in front of you appear the GUI .
step 2 -> select File->new->Android Application Project
and fill all the filed as show in image


step 3-> Click Next->Next->Next->Next->Finish
Step 4-> On Android Application is Created

Step4->Download the jar file
ksoap2-android-assembly-2.5.5-jar-with-dependencies.jar

Step 5 -> Copy and past in libs folder and write click->Build Path->Configration Build Path

Note - If libs  folder not avable in our project then create new folder name like libs and keep this jar file

step 6 -> Now Write Click on  Project Add->New->Class  [class name like CallSoap.java]

And Write the Code as Shown Below 


import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.PropertyInfo;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.HttpTransportSE;
public class CallSoap {
    public final String SOAP_ACTION = "http://tempuri.org/Add";

    public  final String OPERATION_NAME = "Add";

    public  final String WSDL_TARGET_NAMESPACE = "http://tempuri.org/";

    public  final String SOAP_ADDRESS = "http://179.45.33.245/webservice/WebService.asmx";
    public CallSoap()
    {
    }
    public String Call(int a,int b)
    {
        SoapObject request = new SoapObject(WSDL_TARGET_NAMESPACE,OPERATION_NAME);
        PropertyInfo pi=new PropertyInfo();
        pi.setName("a");
        pi.setValue(a);
        pi.setType(Integer.class);
        request.addProperty(pi);
        pi=new PropertyInfo();
        pi.setName("b");
        pi.setValue(b);
        pi.setType(Integer.class);
        request.addProperty(pi);

        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
                SoapEnvelope.VER11);
        envelope.dotNet = true;

        envelope.setOutputSoapObject(request);

        HttpTransportSE httpTransport = new HttpTransportSE(SOAP_ADDRESS);
        Object response=null;
        try
        {
            httpTransport.call(SOAP_ACTION, envelope);
            response = envelope.getResponse();
        }
        catch (Exception exception)
        {
            response=exception.toString();
        }
        return response.toString();
    }
}

step 7 -> open activity_main.xml and copy and past the code

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="hello" />

    <EditText
        android:id="@+id/editText1"
        android:layout_width="230dp"
        android:layout_height="wrap_content" >

        <requestFocus />
    </EditText>

    <EditText
        android:id="@+id/editText2"
        android:layout_width="232dp"
        android:layout_height="wrap_content" />
   
   
  
   

    <Button
        android:id="@+id/button1"
        android:layout_width="229dp"
        android:layout_height="wrap_content"
        android:text="submit" />

   

</LinearLayout>
 
Step 8 -> Open the MainActivity.java

And write the code as shown below

import android.R.string;
import android.os.Bundle;
import android.os.StrictMode;
import android.app.Activity;
import android.app.AlertDialog;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends Activity {

    private TextView textDisplay;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (android.os.Build.VERSION.SDK_INT > 9) {
            StrictMode.ThreadPolicy policy =
                new StrictMode.ThreadPolicy.Builder().permitAll().build();
            StrictMode.setThreadPolicy(policy);
        }
        setContentView(R.layout.activity_main);
        Button b1=(Button)findViewById(R.id.button1);
        //textDisplay =(TextView)findViewById(R.id.text);
        //textDisplay.setText("heloo");
        final  AlertDialog ad=new AlertDialog.Builder(this).create();

        b1.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                CallSoap cs=new CallSoap();
                //soapshowrecord showrec=new soapshowrecord();               
                try
                {
                    EditText ed1=(EditText)findViewById(R.id.editText1);
                    EditText ed2=(EditText)findViewById(R.id.editText2);
                    int a=Integer.parseInt(ed1.getText().toString());
                    int b=Integer.parseInt(ed2.getText().toString());
                    //EditText ed3=(EditText)findViewById(R.id.text);
                    //String record=(ed3.getText().toString());
                    ad.setTitle("OUTPUT OF ADD of "+a+" and "+b);
                   
                    //String resp1=showrec.Call1(record);
                    //record=resp1;
                   
                    String resp=cs.Call(a, b);
                    ad.setMessage(resp);
                }catch(Exception ex)
                {
                    ad.setTitle("Error!");
                    ad.setMessage(ex.toString());
                }
                ad.show(); }
        });
    }

}

Output as shown Below



Tuesday 16 July 2013

Image slider in asp.net using jquery

create simple drop down menu using jquery
 Categories :- Image Slider In asp.net with example

Introduction : -

This is very easy  to implement the slider in  asp.net .In my previous article i have explained very nice example for implement the slider in asp.net.
This is very simple and easy to use  slider in our web page. in this post you can adjust the width and height as well as time delay of image

In this article you have to include a one .js file like this



<script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>

Jquey Function is like this



<script type="text/javascript">
        $(document).ready(function () {

            var currentPosition = 0;
            var slideWidth = 600;
            var slides = $('.slide');
            var numberOfSlides = slides.length;
            var slideShowInterval;
            var speed = 2000;


            slideShowInterval = setInterval(changePosition, speed);

            slides.wrapAll('<div id="slidesHolder"></div>')

            slides.css({ 'float': 'left' });

            $('#slidesHolder').css('width', slideWidth * numberOfSlides);


            function changePosition() {
                if (currentPosition == numberOfSlides - 1) {
                    currentPosition = 0;
                } else {
                    currentPosition++;
                }
                moveSlide();
            }


            function moveSlide() {
                $('#slidesHolder')
                  .animate({ 'marginLeft': slideWidth * (-currentPosition) });
            }

        });

    </script>

Complete  Source As shown below

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
     <script type="text/javascript" src="Scripts/jquery-1.4.1.js"></script>
    <style type="text/css">
        #slideshow #slideshowWindow
        {
     
    width:512px;
    height:200px;
    margin:0;
    padding:0;
    position:relative;
    overflow:hidden;
        }

    #slideshow #slideshowWindow .slide {
    margin:0;
    padding:0;
    width:512px;
    height:384px;
    float:left;
    position:relative;
        }
   </style>

    <script type="text/javascript">
        $(document).ready(function () {

            var currentPosition = 0;
            var slideWidth = 600;
            var slides = $('.slide');
            var numberOfSlides = slides.length;
            var slideShowInterval;
            var speed = 2000;


            slideShowInterval = setInterval(changePosition, speed);

            slides.wrapAll('<div id="slidesHolder"></div>')

            slides.css({ 'float': 'left' });

            $('#slidesHolder').css('width', slideWidth * numberOfSlides);


            function changePosition() {
                if (currentPosition == numberOfSlides - 1) {
                    currentPosition = 0;
                } else {
                    currentPosition++;
                }
                moveSlide();
            }


            function moveSlide() {
                $('#slidesHolder')
                  .animate({ 'marginLeft': slideWidth * (-currentPosition) });
            }

        });

    </script>

</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div id="slideshow">
    <div id="slideshowWindow">
   
        <div class="slide">
            <img src="img/1.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/2.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/3.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div><!--/slide-->
       
        <div class="slide">
            <img src="img/4.jpg" alt="http://dotnetnukes.blogspot.in"/>
        </div>
       
    </div>
</div>
</center>
    </form> 
   
</body>
</html>




Download sample code attached






Image slider in asp net

Image slider in asp net
Introduction :- 
 In this Post i am explain how i can implement the slider in asp.net.This is very easy to implement the slider in asp.net.

Description : -

In my previous post i have explained  implement the drop down menu using jquery. Here i am explain implement the j query slider in asp.net .

In this Post first we  include the  .js and .css file in our page .Image as show below


Inculde .js and .css  on asp.net page as shown below



<head runat="server">
    <title>Slider in asp.net</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="Styles/coin-slider.js"></script>

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />
</head>

In This  slider you can set the width and height of the slider image as shown below
You can control the speed and delay of image and set width and height according to you web page this script write in jqueryslider.js .Full Source Code You Can Download link are give below


$.fn.coinslider.defaults = {
        width: 700, // width of slider panel
        height: 200, // height of slider panel
        spw: 7, // squares per width
        sph: 5, // squares per height
        delay: 1000, // delay between images in ms
        sDelay: 30, // delay beetwen squares in ms
        opacity: 0.7, // opacity of title and navigation
        titleSpeed: 500, // speed of title appereance in ms
        effect: '', // random, swirl, rain, straight
        links : true, // show images as links
        hoverPause: true, // pause on hover
        prevText: 'prev',
        nextText: 'next',
        navigation: true, // show/hide prev, next and buttons
        showNavigationPrevNext: true,
        showNavigationButtons: true,
        navigationPrevNextAlwaysShown: false
    };

Complete code as shown below



<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Slider in asp.net</title>

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
    <script type="text/javascript" src="Styles/coin-slider.js"></script>

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />

    <link rel="stylesheet" href="Styles/coin-slider-styles.css" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <center>
    <div id="games">
    <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/1.jpg" alt="http://dotnetnukes.blogspot.in" /></a>
     <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/2.jpg"alt="http://dotnetnukes.blogspot.in"  /></a>
      <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/3.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
       <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/4.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
        <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/5.jpg" alt="http://dotnetnukes.blogspot.in"  /></a>
         <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/6.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
         <a href=http://dotnetnukes.blogspot.in target="_blank"><img src="img/7.jpg"  alt="http://dotnetnukes.blogspot.in" /></a>
    </div>
    </center>
    </form>

    <script>
        $('#games').coinslider();
        </script>
</body>
</html>



Download sample code attached







 

..




New Updates

Related Posts Plugin for WordPress, Blogger...

Related Result