blogspot visit counter

Friday 29 November 2013

Role of CLR in Dotnet Framework

Role of CLR in Dotnet Framework Interview Question
1 ) CLR Provides an environment to execute .Net Applications on target machines.

2) CLR is also a common runtime environment  for all .NET code irrespective  of their programming language, because the compilers of .NET framework convert every source code into a common language known a MSIL
3) CLR also provide various services to execute processes, such as memory management service and security services, CLR performs various tasks to manage the execution process of .NET application.

The list of CLR as shown below.....

Automatics memory management  -> CLR invokes various built-in-functions of .NET framework to allocate and de- allocate the memory of .NRT object.

Garbage Collection -> Garbage Collection is the major role of CLR, which prevents memory leaks during execution of program. The Garbage collector of CLR automatically determines the best time to free the memory, which is reserved by an object for execution .

Code Access Security  -> Code Access Security(CAS) model is used in .NET framework to impose restrictions and security during execution of programs.

Code Verification -> CLR enforces type safety and prevents a source code from performing illegal operations, such as accessing invalid memory location.

JIT compilation of .NET code -> CLR uses the services of the just-in-time(JIT) compiler to load MSIL code on traget machine for execution.

Monday 28 October 2013

Json with integer in php

Json with integer in php
Introduction :-
Here i am explain how to use  PHP  json_encode function.

In some cases numeric data may  appear as numeric strings, for example 1 as "1". While consuming the json data on a client app that would mean an extra parsing to get for example an int from the string.

The solution is to simply use an extra option (JSON_NUMERIC_CHECK) on the json_encode function call:

then you will not get the data in string format.You get the data like 1 without double quotes

use for json_encode
   



<?php echo json_encode($data, JSON_NUMERIC_CHECK); ?>

For example

{"data":[{"x":0,"y":0,"username":"%s","gender":"%s","location":"%s","id":"%s","age":30},{"x":0,"y":0,"username":"Ranvijay Singh","gender":"male","location":"Navi Mumbai (New Mumbai), India","id":1179445904,"age":30},{"x":10,"y":20,"username":"aman","gender":"male","location":"indore","id":123,"age":30}]}


Here x and y is integer values then not show double quotes

Thursday 24 October 2013

How to Change Table Name in MySQL

Introduction :-
If you want to change the Table name without loss you data then it's very simple to change the table in MySQL database and sql server database.

Description : -

To change the name of an existing table first to second, use this command as shown below


RENAME TABLE first TO second;

For Example

You have table name like stodent_tab
and there are four fields like First_name,Last_Name,Stud_ID,Stud_Batch
and you want to change the name of  stodent_tab because you have done mistake in student_tab name

So Query Like This


RENAME TABLE stodent_tab TO student_tab;

Note -: This query is same if you want to use the sql server database.

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
.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.

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.



Step 1 :- Create table  for generate xml file using mysql database. Table structure as show below


CREATE TABLE `user_tab` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `User_Name` varchar(50) DEFAULT NULL,
  `Contact_No` varchar(50) DEFAULT NULL,
  `Donet_Values` float DEFAULT NULL,
  `Donate_Date` datetime DEFAULT NULL,
  `User_Email` varchar(50) DEFAULT NULL,
  PRIMARY KEY (`ID`)
)

GUI table structure as show below


Step 2:- create a new asp.net web  application and add  new page and write this code on web page as show below


//generat xml file and save in folder
    protected void Button1_Click(object sender, EventArgs e)
    {
        MySqlConnection con = new MySqlConnection("server=localhost;User Id=root;database=database Name;password=Your Password;Pooling=false;");
        con.Open();
        string str = "select * from slider_tab1 ";
        MySqlDataAdapter da = new MySqlDataAdapter(str,con);
        DataSet ds = new DataSet();
        da.Fill(ds,"Userinfo");
        ds.WriteXml(Server.MapPath("~/xmlfile/xml_file.xml"));
        lblmsg.Text = "XML File Created Successfully";
      
    }

Explanation -: Here i take a new asp.net web page and drag and drop  a asp.net button and one label for show the message file is created and write this code on asp.net button click event.

In this code i  have selected  all the data from mysql  database and create a object of mysql DataAdapter and create DaSet and fill all the DataAdapter values in Dataset and save the file in xml format in  xmlfile folder

Note- If you use mysql database then use the mysql to asp.net connector for connect the MySQL database to 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 18 September 2013

Timestamp in mysql

Timestamp in mysql
TimeStamp : -
The TIMESTAMP data type is the only way to have MySQL automatically set the time when a row was inserted and/or updated. DATETIME columns can’t do this.
TIMESTAMP columns are identical to DATETIME columns with one important exception — they can be set to take the current time value when a row is created or updated.


Note  -  If you want to use a timestamp  column then  set Defalut as shown



create table using timestamp as shown below

CREATE TABLE IF NOT EXISTS `user_tab` (
  `x` varchar(200) NOT NULL,
  `y` varchar(200) NOT NULL,
  `id` varchar(200) NOT NULL,
  `usertime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)

GUI  structure as  shown below





Note - if you set defaut  as a timestamp then don not use the time stamp column name at the time of insertion  it automaticlay insert the time in timestamp column

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

How to Change a Column Name in MySQL

How to Change a Column Name in MySQL
Introduction : -
In this article i am explain how i can change the column name of MySQL database table

Description :-

This is very to change the table column name in mysql database.
I have a info_tab (this is table name). And  id , user_id, Fisrt_Name, LastName

table as shown below




alter table info_tab change First_Name2 First_name varchar(30)

Here info_tab is table name 
First_Name2  is  old column name  which you want to change
Fist_Name Is new Column name  of the table

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



Description : - 

 In my Previous article i have explained how to upload  only image in .png,.jpeg format.  Now I am explain how to solve the server error could not find file when file is uploaded in image folder using file upload control of  asp.net.

Solution :- 

Use Server.MapPath for upload file in folder. Process for upload file on server side as shown below.

Create a  new  website and add new web Form .give the name to the web Form fileupload.aspx  .And drag and drop a new asp.net file upload control and asp.net button control. and double click on  button that means on code behind side write this code on button click event.




  protected void Button1_Click(object sender, EventArgs e)
    {
        string image1 = File1.FileName.ToString();
        string imgPath1 = "~/image/"+ image1;
        File1.SaveAs(Server.MapPath(imgPath1));
    }


 Here "~/image/" virtual path of the image  folder.



Download sample code attached




Friday 9 August 2013

How To Change Hyperlink Underline Color

Code To Change Hyperlink Underline Color

Code
<a href="change-underline-color.php" style="text-decoration: none; border-bottom: 1px solid #999999">change underline color</a>
Output
change underline color

Explanation -

1px = Variable border width in pixels which in this case is used as the hyperlink underline width.
solid = Border style.
#999999 = Color code. Use this variable to change the underline color. Replace this value with your choice of color codes. 

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







Thursday 1 August 2013

How to Add Jump Breaks To Blog Post

Jump Break is a HTML tag which is used to create expandable post summaries in your blog posts, so longer blog posts will displayed in a smaller portion with a link to Read More. You can easily create jump breaks in your blog posts by using blogger's new Post Editor, without the need of any HTML knowledge. Before adding jump breaks in your blog post you must decide where you want to the jump breaks to appear with Read More option. So, here I am going to explain how to insert a jump breaks anywhere in your blog posts.

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



Related Posts Plugin for WordPress, Blogger...