Thursday 5 December 2013

How to Install Crystal Report in Visual studio 2010..

In Previous posts I explained 
How Ajax controls works in asp.net , How Radio button works in aps.net for the beginners and How AJAX timer control works Now I will explain how to Install Crystal Report in Visual Studio 2010. because By default Visual Studio 2010 does not include Crystal Reports hence you need to download the Crystal Reports. here 
I am explain how to install crystal Report and Integrate it in visual Studio 2010..

if you make a new web application in visual studio and When you try to add Crystal Reports in Visual Studio project you get the following screen


The above screen means that you have not installed the Crystal Reports for Visual Studio 2010.
 Downloading the Crystal Reports Installation
Firstly you need to visit the following URL
Then you need to click on the following link as shown in the screenshot below


when you scroll down webpage then the red arrow link you have to follow then installation will begin
in the above table click on the last link ..

after Complete Downloading you will receive compressed file then double click on that and installation will being .. it will take half and hour to install ...




then you can use crystal report in Visual Studio now when you add a crystal report in your application then you will see below kind of Crystal Report Page

this Dialog box will be open and in back your crystal report .. this means crystal report is successfully Integrate inside Visual Studio 2010
if any problem you can ask me or leave a comment on this link 

in my next section i will explain how to use crystal report via database data.. to see that follow this link...



Thanks & Regards

Varun Kumar






How to create Crystal Report in Asp.net using Database ,how to build Crystal Report, how to use Crystal report


Sunday 1 December 2013

How AJAX timer control works

Ajax Timer control performs postbacks at defined intervals. If you use the Timer control with an Update Panel control, you can enable partial-page updates at a defined interval. You can also use the Timer control to post the whole page.

You use the Timer control when you want to do the following:
·         Periodically update the contents of one or more Update Panel controls without refreshing the whole Web page.
·         Run code on the server every time that a Timer control causes a postback.
·         Synchronously post the whole Web page to the Web server at defined intervals.


         Background Details of Ajax Timer Control

·         The Timer control is a server control that embeds a JavaScript component into the Web page. The JavaScript component initiates the postback from the browser when the interval that is defined in the Interval property has elapsed. You set the properties for the Timer control in code that runs on the server and those properties are passed to the JavaScript component.
·         An instance of the ScriptManager class must be included in the Web page when you use the Timer control.
·         When a postback was initiated by the Timer control, the Timer control raises the Tickevent on the server. You can create an event handler for the Tick event to perform actions when the page is posted to the server.

On the Default.aspx page, I have inserted the following lines of code

  <div id="headright" style="width:49%; height:200px; border:2px solid red; float:right;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
         <center><h1>TIME ON LABEL WITHOUT AJAX TIMER CONTORL</h1></center>
          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
          <center><h2 style="color:red;"><asp:Label ID="lblajaxtime" runat="server" Text="Show Time with ajax "></asp:Label></h2></center>
         
          <center> <asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
              </asp:Timer>
   </center>
             
         </ContentTemplate>
        </asp:UpdatePanel>
          </div>
   

Set the Interval property to specify how often postbacks will occur, and set the Enabled property to turn the Timer on or off. The Interval property is defined in milliseconds and has a default value of 60,000 milliseconds, or 60 seconds.

you can set the timer INTERVAL property by using select the timer contorol and open the properties window
or set at the design time time will be in milliseconds .

On the Default.aspx.cs page, I have the following lines of code:

protected void Timer1_Tick(object sender, EventArgs e)
    {
        lblajaxtime.Text = DateTime.Now.ToString();
    }


Design of the page will be like this

now the timer will be run like a watch

now enjoy this post if any query regarding this you can ask me... on my blog..
you can create a countdown timer with this control i will explain this in my next post..

thank you



Thursday 28 November 2013

How Ajax controls works in asp.net

AJAX is about updating parts of a web page, without reloading the whole page.

AJAX = Asynchronous JavaScript and XML.
AJAX is a technique for creating fast and dynamic web pages.
AJAX allows web pages to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. This means that it is possible to update parts of a web page, without reloading the whole page.

AJAX provide the Partial post back of a page. means the only uneatable portion of the web page will be processed..

in visual studio 2008/2010 have inbuilt Ajax  Extension Tab in Toolbox with some controls like below


  1. Ajax script manager
  2. update panel
  3. timer
  4. update progress

above four are the main control of ajax
in this section i will explain how ajax update panel works...

Many developers, when first using ASP.NET AJAX, start with the UpdatePanel control. If a ScriptManager control is included on the page and the UpdatePanel contains any controls, the controls within UpdatePanel can be asynchronously updated through the facilities of AJAX


NOTE : if you want to use ajax controls then you have to user ajax script manager . script manager identify all the ajax controls on the page ... one ajax script manager for one page.... and you can use many ajax controls.. and it could be place inside <form></form> tag

now design you form like this 

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

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div id="header" style="width:99%; height:inherit;">
        <div id="headleft" style="width:50%; height:200px; border:2px solid Green; float:left;">
          <center><h1>TIME ON LABEL WITHOUT AJAX CONTORL</h1></center>
          <center><h2 style="color:Green;"><asp:Label ID="lbltime" runat="server" Text="Show Time"></asp:Label></h2></center>
          
          <center><asp:Button ID="btntime" runat="server" Text="Click to Time" 
                  onclick="btntime_Click" /></center>
                  </div>

        <div id="headright" style="width:49%; height:200px; border:2px solid red; float:right;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
         <center><h1>TIME ON LABEL WITHOUT AJAX CONTORL</h1></center>
          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
          <center><h2 style="color:red;"><asp:Label ID="lblajaxtime" runat="server" Text="Show Time WITH ajax"></asp:Label></h2></center>
          
          <center><asp:Button ID="btnajaxtime" runat="server" Text="Click to AJAX Time" 
                  onclick="btnajaxtime_Click" /></center>
         </ContentTemplate>
        </asp:UpdatePanel>
       </div>
    
    </div>
    </form>
</body>
</html>

this code contains two label and two button with two different divison tag ....one is simple ordinary button and label and secon is inside a ajax contorls..

and design will be look like the above

design of page when you type or paste above code then you will see the desing
red division have same controls like green one but red div label and button are place inside the ajax update panel..   like

          <asp:UpdatePanel ID="UpdatePanel1" runat="server">
          <ContentTemplate>
          <center><h2 style="color:red;"><asp:Label ID="lblajaxtime" runat="server" Text="Show Time WITH ajax"></asp:Label></h2></center>
          
          <center><asp:Button ID="btnajaxtime" runat="server" Text="Click to AJAX Time" 
                  onclick="btnajaxtime_Click" /></center>
         </ContentTemplate>
        </asp:UpdatePanel>


when you click on click to time button then full page is refresed and get loaded with all contorls.. and sign is page is reloaded.. 

code page of this contorl is 


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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btntime_Click(object sender, EventArgs e)
    {
        lbltime.Text = DateTime.Now.ToString();
    }
    protected void btnajaxtime_Click(object sender, EventArgs e)
    {
        lblajaxtime.Text = DateTime.Now.ToString();
    }
}

when you click on the click to ajax time then full page is not refreshed and partially page is refersed.. means only the content within update panel is post to server and get reloaded....

you can also use this update panel to get the data from the database on a button click...

or you can run this time regularly like a watch running without click on a button ..

there is another contorl which is AJAX TIMER CONTROL.. this will help you to run a time or get the data from the database without and event occure but after a specified time it will call

to see the ajax timer contorl follow the below link


so enjoy the simple ajax update panel contorl if any query regarding this post or any other question regarding asp.net and database must write inside comment...


thank you happy asp.net 








how to make possible that one radio button will be selected at once in asp.net

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

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
   
    <form id="form1" runat="server">
    <div>
    <asp:RadioButton ID="RadioButton1"  GroupName="Gender" Text="Male" runat="server" /><br /><br />
    <asp:RadioButton ID="RadioButton2"  GroupName="Gender" Text="Female" runat="server" />
    <br />
    </div>
    </form>

</body>
</html>



when you debug this application if you click on one without specify the group name property of radio button then both will be selected at once... 

To remove this kind of problem specify the Group Name property of both the radio button ..

again debug this it will work like it should be.. 


Thank you