Monday, January 31, 2011

How to check file IsReadOnly in asp.net

FileIsReadOnly.aspx

<%@ Page Language="C#" %>  
<%@ Import Namespace="System.IO" %>  
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  
<script runat="server">  
    protected void Page_Load(object sender, System.EventArgs e) {  
        System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("Text.Txt"));  
        Label1.Text = "Your File IsReadOnly?: " +  
            file.IsReadOnly.ToString();  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>FileInfo class example: how to check file IsReadOnly in asp.net</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>  
    </div>  
    </form>  
</body>  
</html>  


How to check file Exists or not in asp.net


FileExists.aspx
<%@ Page Language="C#" %>
<%@ Import Namespace="System.IO" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<script runat="server">
    protected void Page_Load(object sender, System.EventArgs e) {
        System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("Text.Txt"));
        Label1.Text = "Your File Exists?: " +
            file.Exists.ToString();
    }
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>FileInfo class example: how to check file Exists or not in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>
    </div>
    </form>
</body>
</html>

Tuesday, January 25, 2011

To use ShowStartingNode property in SiteMapDataSource

SiteMapDataSource.aspx





<%@ Page Language="C#" %>  
<script runat="server">  
    protected void Button1_Click(object sender, System.EventArgs e)  
    {  
        SiteMapDataSource1.ShowStartingNode = false;  
    }  
    protected void Button2_Click(object sender, System.EventArgs e)  
    {  
        SiteMapDataSource1.ShowStartingNode = true;  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>How to use ShowStartingNode property in SiteMapDataSource</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Navy">SiteMapDataSource Example</h2>  
        <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server"/>  
        <asp:TreeView   
             ID="TreeView1"  
             runat="server"  
             DataSourceID="SiteMapDataSource1"  
             Width="250"  
             BackColor="PaleVioletRed"  
             ForeColor="Wheat"  
             Font-Bold="true"  
             Font-Italic="true"  
             >  
        </asp:TreeView>  
        <br />  
        <asp:Button   
             ID="Button1"   
             runat="server"  
             ForeColor="SaddleBrown"  
             Text="ShowStartingNode False"  
             Height="45"  
             OnClick="Button1_Click"  
             Font-Bold="true"  
             />  
        <asp:Button   
             ID="Button2"   
             runat="server"  
             ForeColor="SaddleBrown"  
             Text="ShowStartingNode True"  
             Height="45"  
             OnClick="Button2_Click"  
             Font-Bold="true"  
             />  
    </div>  
    </form>  
</body>  
</html>  

Asp.Net Web.sitemap Example: a sample Web.sitemap file


<?xml version="1.0" encoding="utf-8" ?>  
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >  
    <siteMapNode url="Default.aspx" title="Home"  description="Home Page">  
      <siteMapNode url="StandardToolBox.aspx" title="StandardToolBox" description="StandardToolBox Controls">  
        <siteMapNode url="AdRotatorExample.aspx" title="AdRotator"  description="AdRotator Example" />  
        <siteMapNode url="BulletedListExample.aspx" title="BulletedList"  description="BuulletedList Example" />  
        <siteMapNode url="ButtonExample.aspx" title="Button"  description="Button Example" />  
        <siteMapNode url="CalendarExample.aspx" title="Calendar"  description="Calendar Example" />  
      </siteMapNode>  
      <siteMapNode url="DataToolBox.aspx" title="DataToolBox" description="DataToolBox controls">  
        <siteMapNode url="ListViewExample.aspx" title="ListView"  description="ListView Example" />  
        <siteMapNode url="GridViewExample.aspx" title="GridView"  description="GridView Example" />  
      </siteMapNode>  
      <siteMapNode url="NavigationToolbox.aspx" title="Navigation Toolbox" description="NavigationToolbox controls">  
        <siteMapNode url="MenuExample.aspx" title="Menu"  description="Menu Example" />  
        <siteMapNode url="SiteMapPathExample.aspx" title="SiteMapPath"  description="SiteMapPath Example" />  
        <siteMapNode url="TreeViewExample.aspx" title="TreeView"  description="TreeView Example" />  
      </siteMapNode>  
    </siteMapNode>  
</siteMap>  

To set change Chart Series MarkerStep programmatically in asp.net

ChartSeriesMarkerStep.aspx 




<%@ Page Language="C#" AutoEventWireup="true" %>  

<script runat="server">  


    protected void Button1_Click(object sender, System.EventArgs e)  
    {  
        Chart1.Series["NokiaPhone"].MarkerStep = 2;  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head id="Head1" runat="server">  
    <title>How to set change Chart Series MarkerStep programmatically in asp.net</title>  
    <style type="text/css">  
        h2  
        {  
            color:DarkBlue;  
            font-style:italic;  
            }  
    </style>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2>Chart example and tutorial: How to set change<br /> Chart Series MarkerStep programmatically in asp.net</h2>  
        <hr width="625" align="left" color="CornFlowerBlue" />  
        <br />  
        <asp:Chart   
            ID="Chart1"   
            runat="server"  
            Width="625"   
            BackColor="Maroon"  
            BorderlineColor="Orchid"  
            BorderlineDashStyle="Solid"  
            BorderlineWidth="2"  
            >  
            <Series>  
                <asp:Series   
                    Name="NokiaPhone"   
                    YValueType="Double"   
                    ChartArea="DefaultChartArea"  
                    ChartType="Bar"  
                    MarkerStyle="Circle"  
                    Color="DarkRed"  
                    MarkerColor="Green"  
                    MarkerSize="10"  
                    >  
                    <Points>  
                        <asp:DataPoint AxisLabel="Nokia N8" YValues="549" />  
                        <asp:DataPoint AxisLabel="Nokia N97 Mini Driver Ed." YValues="399.99" />  
                        <asp:DataPoint AxisLabel="Nokia N97 mini" YValues="379.99" />  
                        <asp:DataPoint AxisLabel="Nokia E72 Driver Edition" YValues="349" />  
                        <asp:DataPoint AxisLabel="Nokia 5800 Driver Edition" YValues="289" />  
                    </Points>  
                </asp:Series>  
            </Series>  
            <ChartAreas>  
                <asp:ChartArea   
                    Name="DefaultChartArea"   
                    BorderDashStyle="Solid"  
                    BorderWidth="2"  
                    BorderColor="OrangeRed"  
                    BackColor="Orange"  
                    >  
                    <Area3DStyle Enable3D="true" LightStyle="Realistic" />  
                    <AxisX>  
                        <LabelStyle ForeColor="Snow" />  
                        <MajorGrid LineColor="Salmon" />  
                    </AxisX>  
                    <AxisY>  
                        <LabelStyle ForeColor="Snow" />  
                        <MajorGrid LineColor="Salmon" />  
                    </AxisY>  
                </asp:ChartArea>  
            </ChartAreas>  
        </asp:Chart>  
        <br />  
        <asp:Button   
            ID="Button1"  
            runat="server"  
            Text="Set Chart Series MarkerStep 2"  
            Font-Bold="true"  
            OnClick="Button1_Click"  
            ForeColor="DarkBlue"  
            Height="45"  
            />  
    </div>  
    </form>  
</body>  
</html>

Thursday, January 13, 2011

In AJAX AutoCompleteExtender TextBox CompletionList Width

Progress Image in AutoComplete TextBox


<head runat="server">
    <title>Progress Image in AutoComplete TextBox</title>
<style>
        .AutoExtender
        {
            font-family: Verdana, Helvetica, sans-serif;
            font-size: .8em;
            font-weight: normal;
            border: solid 1px #006699;
            line-height: 20px;
            padding: 10px;
            background-color: White;
            margin-left:10px;
        }
        .AutoExtenderList
        {
            border-bottom: dotted 1px #006699;
            cursor: pointer;
            color: Maroon;
        }
        .AutoExtenderHighlight
        {
            color: White;
            background-color: #006699;
            cursor: pointer;
        }
        #divwidth
        {
          width: 150px !important;  
        }
        #divwidth div
       {
        width: 150px !important;
       }
 </style>
</head>
 Put a div with id "divwidth" above the html source of autocomplete extender.
<div ID="divwidth"></div>
and add this line in autocomplete extender HTML source
CompletionListElementID="divwidth"
The complete html source of AutoComplete Extender



<asp:TextBox ID="txtAutoComplete" runat="server" Width="252px">
</asp:TextBox>
<div ID="divwidth"></div>
<ajaxToolkit:AutoCompleteExtender runat="server"
             ID="AutoComplete1"
             BehaviorID="autoComplete"
             TargetControlID="txtAutoComplete"
             ServicePath="AutoComplete.asmx"
             ServiceMethod="GetCompletionList"
             MinimumPrefixLength="1"
             CompletionInterval="10"
             EnableCaching="true"
             CompletionSetCount="12"
             CompletionListCssClass="AutoExtender"
             CompletionListItemCssClass="AutoExtenderList"
             CompletionListHighlightedItemCssClass
             ="AutoExtenderHighlight"
             CompletionListElementID="divwidth">
<ajaxToolkit:AutoCompleteExtender>



To set change ScrollContents property programmatically in CollapsiblePanelExtender

CollapsiblePanelExtender




<%@ Page Language="C#" AutoEventWireup="true" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
        CollapsiblePanelExtender1.ScrollContents = true;
    }
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Ajax CollapsiblePanelExtender - How to set change ScrollContents property programmatically in CollapsiblePanelExtender</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:DodgerBlue; font-style:italic;">
            Ajax CollapsiblePanelExtender - How to set change
            <br /> ScrollContents property programmatically in
            <br /> CollapsiblePanelExtender in asp.net
        </h2>
        <hr width="500" align="left" color="SkyBlue" />
        <asp:ScriptManager
            ID="ScriptManager1"
            runat="server"
            >
        </asp:ScriptManager>
        <cc1:CollapsiblePanelExtender
            ID="CollapsiblePanelExtender1"
            runat="server"
            TargetControlID="Panel2"
            ExpandControlID="Panel1"
            CollapseControlID="Panel1"
            TextLabelID="Label1"
            ExpandedText="-"
            CollapsedText="+"
            Collapsed="true"
            ExpandedSize="250"
            >
        </cc1:CollapsiblePanelExtender>
        <asp:Label
            ID="Label1"
            runat="server"
            ForeColor="DodgerBlue"
            Font-Italic="false"
            Font-Names="Comic Sans MS"
            Font-Size="XX-Large"
            >
        </asp:Label>
        <asp:Panel
            ID="Panel1"
            runat="server"
            Width="100"
            BackColor="Salmon"
            BorderColor="DarkRed"
            BorderWidth="2"
            HorizontalAlign="Center"
            BorderStyle="Solid"
            >
            <asp:Image
                ID="Image1"
                runat="server"
                ImageUrl="~/Image/Hamster.jpg"
                Height="75"
                />
        </asp:Panel>
        <asp:Panel
            ID="Panel2"
            runat="server"
            Width="350"
            BorderColor="Purple"
            BorderWidth="2"
            BackColor="RosyBrown"
            HorizontalAlign="Center"
            >
            <asp:Image
                ID="Image2"
                runat="server"
                ImageUrl="~/Image/Hamster.jpg"
                Height="325"
                />
        </asp:Panel>
    </div>
    </form>
</body>
</html>

Tuesday, January 11, 2011

Storing Data in Veiw State ::

ViewStateDataStore.aspx





<%@ Page Language="C#" %>  
  
  
<script runat="server">  
    protected void Button1_Click(object sender, System.EventArgs e)  
    {  
        ViewState["Name"] = TextBox1.Text.ToString();  
        Label1.Text = "Your name saved in ViewState.";  
    }  
    protected void Button2_Click(object sender, System.EventArgs e)  
    {  
        string name = (string)ViewState["Name"];  
          
        Label1.Text = "Hi " + name + "! we found your name in ViewState.";  
    }  
</script>  
  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head runat="server">  
    <title>asp.net ViewState example: how to store (save) data in ViewState</title>  
</head>  
<body>  
    <form id="form1" runat="server">  
    <div>  
        <h2 style="color:Red">asp.net ViewState example: data store</h2>  
        <asp:Label   
            ID="Label1"   
            runat="server"  
            Font-Size="Large"  
            ForeColor="Teal"  
            >  
        </asp:Label>  
        <br /><br />  
        <asp:Label ID="Label2" runat="server" Text="Your Name" ForeColor="Green">  
        </asp:Label>  
        <asp:TextBox ID="TextBox1" runat="server" BackColor="Green" ForeColor="AliceBlue">  
        </asp:TextBox>  
        <br />  
        <asp:Button   
            ID="Button1"   
            runat="server"   
            Text="Save data in ViewState"  
            OnClick="Button1_Click"  
            Font-Bold="true"  
            ForeColor="DarkGreen"  
            />  
        <asp:Button   
            ID="Button2"   
            runat="server"   
            Text="Read data from ViewState"  
            OnClick="Button2_Click"  
            Font-Bold="true"  
            ForeColor="DarkGreen"  
            />  
    </div>  
    </form>  
</body>  
</html>  

Dot Net Examples: Driving directions from Google Maps in XML format

Dot Net Examples: Driving directions from Google Maps in XML format: "The Google maps return this document in result of Http request sent by the user which contains the data for direction and distance. You will..."