Welcome to RP's venture...Here you can find some of the relative topics like ASP.Net, C#.Net,VB.Net, SQL Server, AJAX, Javascripts, Sharepoint, WPF, WCF, Silverlight, MVC, General knowledge, Jokes, Fun, Technical, Non-Technical etc.
0

AN OVERVIEW OF THE AZURE SERVICES PLATFORM

Posted by Rajendra Prasad Panchati on Thursday, December 09, 2010 in
     Using computers in the cloud can make lots of sense. Rather than buying and maintaining your own machines, why not exploit the acres of Internet-accessible servers on offer today? For some applications, their code and data might both live in the cloud, where somebody else manages and maintains the systems they use. Alternatively, applications that run inside an organization—on-premises applications—might store data in the cloud or rely on other cloud infrastructure services. Applications that run on desktops and mobile devices can use services in the cloud to synchronize information across many systems or in other ways. However it’s done, exploiting the cloud’s capabilities can improve our world.
    But whether an application runs in the cloud, uses services provided by the cloud, or both, some kind of application platform is required. Viewed broadly, an application platform can be thought of as anything that provides developer-accessible services for creating applications. In the local, on-premises Windows world, for example, this includes technologies such as the .NET Framework, SQL Server, and more. To let applications exploit the cloud, cloud application platforms must also exist. And because there are a variety of ways for applications to use cloud services, different kinds of cloud platforms are useful in different situations.
Microsoft’s Azure Services Platform is a group of cloud technologies, each providing a specific set of services to application developers. As Figure 1 shows, the Azure Services Platform can be used both by applications running in the cloud and by applications running on local systems.

Figure 1: The Azure Services Platform supports applications running in the cloud and on local systems.

    The components of the Azure Services Platform can be used by local applications running on a variety of systems, including various flavors of Windows, mobile devices, and others. Those components include:
Windows Azure: Provides a Windows-based environment for running applications and storing data on servers in Microsoft data centers.
Microsoft .NET Services: Offers distributed infrastructure services to cloud-based and local applications.
Microsoft SQL Services: Provides data services in the cloud based on SQL Server.
Live Services: Through the Live Framework, provides access to data from Microsoft’s Live applications and others. The Live Framework also allows synchronizing this data across desktops and devices, finding and downloading applications, and more.
       Each component of the Azure Services Platform has its own role to play. This overview describes all four, first at a high level, then in a bit more detail. While none of them are yet final—details and more might change before their initial release—it’s not too early to start understanding this new set of platform technologies.

|
1

Excel Practices

Posted by Rajendra Prasad Panchati on Thursday, November 18, 2010
Refer : http://chandoo.org/

|
0

Windows Azure Prerequisites

Posted by Rajendra Prasad Panchati on Thursday, November 18, 2010 in

Common Prerequisites


Windows Azure Platform SDKs & Tools

  • Windows Azure Tools for Microsoft Visual Studio 1.2 (June 2010)
    Windows Azure SDK provides developers APIs, tools, documentation and samples needed to develop applications for internet scale on Windows Azure. Windows Azure Tools for Microsoft Visual Studio extend Visual Studio to enable the creation, building, debugging, running and packaging of scalable services on Windows Azure.
  • Windows Azure platform AppFabric SDK V1.0 - July Update
    The Windows Azure platform AppFabric SDK SDK includes APIs, libraries, samples, and documentation for building connected applications with the .NET platform.

SQL Server & Tools


Windows Identity Foundation

  • Microsoft Windows Identity Foundation Runtime
    Windows Identity Foundation (WIF) is a new extension to the Microsoft .NET Framework that makes it easy for developers to enable advanced identity capabilities in the .NET Framework applications. Based on interoperable, standard protocols, Windows Identity Foundation and the claims-based identity model can be used to enable single sign on, personalization, federation, strong authentication, identity delegation, and other identity capabilities in ASP.NET and Windows Communication Foundation (WCF) applications that run on-premises or in the cloud.
  • Microsoft Windows Identity Foundation SDK
    The Windows Identity Foundation SDK provides templates for use with Visual Studio and code samples.

|
0

Windows Azure Concepts

Posted by Rajendra Prasad Panchati on Friday, October 29, 2010 in
Coming Soon

|
0

Get Row Number in ResultSet

Posted by Rajendra Prasad Panchati on Wednesday, October 27, 2010
SELECT ROW_NUMBER() over(order by Column1) As SNo,Column1 FROM Table.

|
0

Method Overriding in C# with Examples

Posted by Rajendra Prasad Panchati on Friday, August 13, 2010
A tutorial on method overriding in C#

Introduction

Method overriding in C# is a feature like the virtual function in C++. Method overriding is a feature that allows you to invoke functions (that have the same signatures) that belong to different classes in the same hierarchy of inheritance using the base class reference. C# makes use of two keywords: virtual and overrides to accomplish Method overriding. Let's understand this through small examples.

Case 1:

class BC
{
  public void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  new public void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    
  }
}

Output

BC::Display
 
The above program compiles and runs successfully to give the desired output. It consists of a base class BC and a derived class DC. Class BC consists of function Display(). Class DC hides the function Display() it inherited from the base class BC by providing its on implementatin of Display(). Class Demo consists of entrypoint function Main(). Inside Main() we first create a reference b of type BC. Then we create an object of type BC and assign its reference to reference variable b. Using the reference variable b we invoke the function Display(). As expected, Display() of class BC is executed because the reference variable b refers to the object of class BC.
Now we add a twist of lime to the above program.

Case 2:

class BC
{
  public void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  new public void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    
  }
}

Output

BC::Display
BC::Display
 
Here we are creating an object of Derived class DC and storing its reference in the reference variable b of type BC. This is valid in C#. Next, using the reference variable b we invoke the function Display(). Since b contains a reference to object of type DC one would expect the function Display() of class DC to get executed. But that does not happen. Instead what is executed is the Display() of BC class. That's because the function is invoked based on type of the reference and not to what the reference variable b refers to. Since b is a reference of type BC, the function Display() of class BC will be invoked, no matter whom b refers to. Take one more example.

Case 3:

class BC
{
  public void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  new public void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class TC : BC
{
  new public void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    

     b = new TC();
     b.Display();    
  }
}

Output

BC::Display
BC::Display
BC::Display
 
The output of the above program is a receipt of the fact that no matter to whom base class reference b refers, it invokes the functions of the class that matches its type. But doesn't this sound absurd? If b contains the reference to a perticular derived class object, then its supposed to invoke the function of that class. Well, C# helps us do this by the usage of keywords virtual and override as shown in the following program.

Case 4:

class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    
  }
}

Output

BC::Display
DC::Display
 
The above program compiles and runs successfully to give the expected desired output. The function Display() of Base class BC is declared as virtual, while the Derived class's implementation of Display() is decorated with the modifier override. Doing so enables C# to invoke functions like Display() based on objects the reference variable refers to and not the type of reference that is invoking the function. Hence in the above program when b refers to the object of class BC it invokes Display() of BC and then when b refers to the object of class DC it invokes Display() of class DC. Let's see if this holds true for the third generation of derived classes. Take the following program.

Case 5:

class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class TC : DC
{
  public override void Display()
  {
     System.Console.WriteLine("TC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;
     b = new BC();
     b.Display();    

     b = new DC();
     b.Display();    

     b = new TC();
     b.Display();    
  }
}

Output

BC::Display
DC::Display
TC::Display
 
The above program compiles and runs successfully to give the expected desired output. The function Display() of Base class BC is declared as virtual, while the implementation of Display() in successive Derived classes is decorated with the modifier override. Next, we succesively create objects of each class and store their reference in base class reference variable b and invoke Display(). The rite versions of Display get invoked based on the object the reference variable refers to. Time for a tiny teaser! Guess what the output would be in the following program?

Case 6:

class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class TC : DC
{

}

class Demo
{
  public static void Main()
  {
     BC b;

     b = new TC();
     b.Display();    
  }
}

Output

DC::Display
 
Since TC has no implementation of Display(), it inherits Display() from DC as TC is derived from DC. Hence Display() from Derived class DC gets executed. It's as if the derived class TC looked like this:
Collapse
class TC 
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}
to the compiler. Take one more example. Guess what its output will be.

Work to the viewer:


class BC
{
  public virtual void Display()
  {
     System.Console.WriteLine("BC::Display");
  }
}

class DC : BC
{
  public override void Display()
  {
     System.Console.WriteLine("DC::Display");
  }
}

class TC : DC
{
  public new void Display()
  {
     System.Console.WriteLine("TC::Display");
  }
}

class Demo
{
  public static void Main()
  {
     BC b;

     b = new TC();
     b.Display();    
  }
}

Output

DC::Display
 
Agreed that TC defines its own new version of Display(). But its version of display is not invoked as Display() of TC does not override the Display() of the base class. With this understood we are done with Method overriding in C#.

|
0

Validator server Controls

Posted by Rajendra Prasad Panchati on Thursday, August 12, 2010
Validation Server Control Description
CompareValidator Compares the value of one input control to the value of another input control or to a fixed value
CustomValidator Allows you to write a method to handle the validation of the value entered
RangeValidator Checks that the user enters a value that falls between two values
RegularExpressionValidator Ensures that the value of an input control matches a specified pattern
RequiredFieldValidator Makes an input control a required field
ValidationSummary Displays a report of all validation errors occurred in a Web page

|
0

Cookies and Session State

Posted by Rajendra Prasad Panchati on Thursday, August 12, 2010
When a user navigates to your site, the server establishes a unique session for that user that lasts for the duration of the user's visit. For each session, ASP.NET maintains session state information where applications can store user-specific information. For more information, see ASP.NET Session State Overview topic.
ASP.NET must track a session ID for each user so that it can map the user to session state information on the server. By default, ASP.NET uses a non-persistent cookie to store the session state. However, if a user has disabled cookies on the browser, session state information cannot be stored in a cookie.
ASP.NET offers an alternative in the form of cookieless sessions. You can configure your application to store session IDs not in a cookie, but in the URLs of pages in your site. If your application relies on session state, you might consider configuring it to use cookieless sessions. However, under some limited circumstances, if the user shares the URL with someone else—perhaps to send the URL to a colleague while the user's session is still active—then both users can end up sharing the same session, with unpredictable results. For more information on configuring your application to use cookieless sessions, see the ASP.NET State Management Overview topic.

|
0

Comparing the GridView and DataGrid Web Server Controls

Posted by Rajendra Prasad Panchati on Thursday, August 12, 2010
The GridView control is the successor to the DataGrid control. Like the DataGrid control, the GridView control was designed to display data in an HTML table. When bound to a data source, the DataGrid and GridView controls each display a row from a DataSource as a row in an output table.
Both the DataGrid and GridView controls are derived from the WebControl class. Although it has a similar object model to that of the DataGrid control, the GridView control also has a number of new features and advantages over the DataGrid control, which include:
  • Richer design-time capabilities.
  • Improved data source binding capabilities.
  • Automatic handling of sorting, paging, updates, and deletes.
  • Additional column types and design-time column operations.
  • A Customized pager user interface (UI) with the PagerTemplate property.
Differences between the GridView control and the DataGrid control include:
  • Different custom-paging support.
  • Different event models.
Improved Design-Time Capabilities

Sorting, paging, and in-place editing of data requires additional coding when using the DataGrid control. The GridView control enables you to add sorting, paging, and editing capabilities without writing any code. Instead, you can automate these tasks, along with other common tasks such as data binding to a data source, by setting properties on the control.
If you are working in a designer, such as Microsoft Visual Studio, you can take advantage of designer features built into the GridView control. The GridView control includes support for a smart tag panel that provides a convenient interface for performing common tasks, such as setting properties and launching template editing.

Improved Data Source Binding Capabilities

Typically a DataSet control, a DbDataReader control, or a collection, such as an Array, an ArrayList, or some other class in the System.Collections namespace, is assigned to the DataSource property of either the DataGrid control or the GridView control. The DataGrid control and the GridView control can bind any object that implements the IEnumerable or IListSource interface.
While the DataGrid control can declaratively bind a DataSourceControl control, it can do so only for data selection. Sorting, paging, updates, and deletions must be coded manually. The GridView control supports a DataSourceID property that takes any object that implements the IDataSource interface and can, therefore, take advantage of the data source control's sorting, paging, updating, and deleting capabilities, for example, the SqlDataSource control.

Additional Column Types

The GridView control supports the following column types: BoundField, HyperLinkField, ButtonField, CommandFieldImageField, and CheckBoxField

Built-In and Custom Paging Support

The DataGrid control requires additional coding for paging. The GridView control automatically supports paging by setting the PagerSettings property. The PagerSettings property supports four modes: Numeric(default), NextPrevious, NumericFirstLast, and NextPreviousFirstLast. The Numeric mode displays numbered page links instead of "next/prev" links, and the NumericFirstLast option adds first and last page links. The GridView control's PagerStyle property can be used to set styles and the position of the pager.
Additionally, you can customize the pager buttons for the GridView control using a PagerTemplate.
Custom paging support in the GridView is supplied by the bound data source control as opposed to the AllowCustomPaging mechanism supplied by the DataGrid control.

Expanded Event Model

The DataGrid and the GridView controls have different event models.
The DataGrid control raises single events for operations, while the GridView control is capable of both pre-operation and post-operation events. The GridView control supports the Sorting event that occurs when a field is sorted. Note that this sorting event occurs before the GridView control automatically handles the sort operation, giving you the opportunity to examine or change the SortExpression property, or cancel this operation by setting the Cancel property to true on the passed event arguments.
The GridView control supports the Sorted event that occurs after the GridView control completes the sort operation, giving you the opportunity to change or format the result of the sort operation. In comparison, the DataGrid control supports the SortCommand event that occurs when a column is sorted. Similarly, the GridView control supports RowUpdating and RowUpdated events that occur before and after the GridView control has automatically handled the update operation. In comparison, the DataGrid control supports the UpdateCommand event that occurs when the Update button is clicked for an item in the grid.

For more information on GridView events, see GridView Web Server Control Events.

|
0

ASP.NET Page Life Cycle Overview

Posted by Rajendra Prasad Panchati on Thursday, August 12, 2010
General Page Life-Cycle Stages


Stage
Description
Page requestThe page request occurs before the page life cycle begins. When the page is requested by a user, ASP.NET determines whether the page needs to be parsed and compiled (therefore beginning the life of a page), or whether a cached version of the page can be sent in response without running the page.
StartIn the start stage, page properties such as Request and Response are set. At this stage, the page also determines whether the request is a postback or a new request and sets the IsPostBack property. The page also sets the UICulture property.
InitializationDuring page initialization, controls on the page are available and each control's UniqueID property is set. A master page and themes are also applied to the page if applicable. If the current request is a postback, the postback data has not yet been loaded and control property values have not been restored to the values from view state.
LoadDuring load, if the current request is a postback, control properties are loaded with information recovered from view state and control state.
Postback event handlingIf the request is a postback, control event handlers are called. After that, the Validate method of all validator controls is called, which sets the IsValid property of individual validator controls and of the page.
RenderingBefore rendering, view state is saved for the page and all controls. During the rendering stage, the page calls the Render method for each control, providing a text writer that writes its output to the OutputStream object of the page's Response property.
UnloadThe Unload event is raised after the page has been fully rendered, sent to the client, and is ready to be discarded. At this point, page properties such as Response and Request are unloaded and cleanup is performed.


  Life-Cycle Events     

Page EventTypical Use
PreInitRaised after the start stage is complete and before the initialization stage begins.
Use this event for the following:
  • Check the IsPostBack property to determine whether this is the first time the page is being processed. The IsCallback and IsCrossPagePostBack properties have also been set at this time.
  • Create or re-create dynamic controls.
  • Set a master page dynamically.
  • Set the Theme property dynamically.
  • Read or set profile property values.
    NoteNote
    If the request is a postback, the values of the controls have not yet been restored from view state. If you set a control property at this stage, its value might be overwritten in the next event.
InitRaised after all controls have been initialized and any skin settings have been applied. The Init event of individual controls occurs before the Init event of the page.
Use this event to read or initialize control properties.
InitCompleteRaised at the end of the page's initialization stage. Only one operation takes place between the Init and InitComplete events: tracking of view state changes is turned on. View state tracking enables controls to persist any values that are programmatically added to the ViewState collection. Until view state tracking is turned on, any values added to view state are lost across postbacks. Controls typically turn on view state tracking immediately after they raise their Init event.
Use this event to make changes to view state that you want to make sure are persisted after the next postback.
PreLoadRaised after the page loads view state for itself and all controls, and after it processes postback data that is included with the Request instance.
LoadThe Page object calls the OnLoad method on the Page object, and then recursively does the same for each child control until the page and all controls are loaded. The Load event of individual controls occurs after the Load event of the page.
Use the OnLoad event method to set properties in controls and to establish database connections.
Control eventsUse these events to handle specific control events, such as a Button control's Click event or a TextBox control's TextChanged event.
NoteNote
In a postback request, if the page contains validator controls, check the IsValid property of the Page and of individual validation controls before performing any processing.
LoadCompleteRaised at the end of the event-handling stage.
Use this event for tasks that require that all other controls on the page be loaded.
PreRenderRaised after the Page object has created all controls that are required in order to render the page, including child controls of composite controls. (To do this, the Page object calls EnsureChildControls for each control and for the page.)
The Page object raises the PreRender event on the Page object, and then recursively does the same for each child control. The PreRender event of individual controls occurs after the PreRender event of the page.
Use the event to make final changes to the contents of the page or its controls before the rendering stage begins.
PreRenderCompleteRaised after each data bound control whose DataSourceID property is set calls its DataBind method. For more information, see Data Binding Events for Data-Bound Controls later in this topic.
SaveStateCompleteRaised after view state and control state have been saved for the page and for all controls. Any changes to the page or controls at this point affect rendering, but the changes will not be retrieved on the next postback.
RenderThis is not an event; instead, at this stage of processing, the Page object calls this method on each control. All ASP.NET Web server controls have a Render method that writes out the control's markup to send to the browser.
If you create a custom control, you typically override this method to output the control's markup. However, if your custom control incorporates only standard ASP.NET Web server controls and no custom markup, you do not need to override the Render method. For more information, see Developing Custom ASP.NET Server Controls.
A user control (an .ascx file) automatically incorporates rendering, so you do not need to explicitly render the control in code.
UnloadRaised for each control and then for the page.
In controls, use this event to do final cleanup for specific controls, such as closing control-specific database connections.
For the page itself, use this event to do final cleanup work, such as closing open files and database connections, or finishing up logging or other request-specific tasks.
NoteNote
During the unload stage, the page and its controls have been rendered, so you cannot make further changes to the response stream. If you attempt to call a method such as the Response.Write method, the page will throw an exception.


                       


|
0

Give Anonymous access to a .Net website on IIS5.1

Posted by Rajendra Prasad Panchati on Wednesday, August 11, 2010

|
0

Display ‘Please Wait’ popup

Posted by Rajendra Prasad Panchati on Tuesday, August 10, 2010

This procedure explains how to add a ‘Please wait’ screen to an ASP.net application.


By default at server process (e.g. saving a request) you only see a progress bar in the status bar.statusBar . If it’s a long running process you might not see any update for a longer time, and users might think that the application stopped, is already finished or did not even start because they did not press the correct button. This might result in double clicks on the Save button or closure of the browser window without completion.
Therefore it is better to display message in the middle of the screen so the user is aware that there is something going on. Current procedure describes how to disable all existing web controls (buttons etc.), coloring all areas in dark gray (fade out) and display an animated circle next to a “Please wait” text.
clip_image002
The procedure has been created based on ASP.net 2005 (2.0) and Microsoft’s Ajax Control Toolkit Release 11119.

CSS

Add the following lines to your CSS file:
/*Modal Popup*/ 
.modalBackground {
    background-color:Gray;
    filter:alpha(opacity=70);
    opacity:0.7;
} 

.modalPopup {
    background-color:#ffffdd;
    border-width:3px;
    border-style:solid;
    border-color:Gray;
    padding:3px;
    text-align:center;
}

.hidden {display:none}

JavaScript

Add the following JavaScript Code to your aspx page:
<script type="text/javascript" language="javascript">

         function pageLoad(sender, args) {
            var sm = Sys.WebForms.PageRequestManager.getInstance();
            if (!sm.get_isInAsyncPostBack()) {
                sm.add_beginRequest(onBeginRequest);
                sm.add_endRequest(onRequestDone);
            }
        }

        function onBeginRequest(sender, args) {
            var send = args.get_postBackElement().value;
            if (displayWait(send) == "yes") {
                $find('PleaseWaitPopup').show();
            }
        }

        function onRequestDone() {
             $find('PleaseWaitPopup').hide();
        }

        function displayWait(send) {
            switch (send) {
                case "Save":
                    return ("yes");
                    break;
                case "Save and Close":
                    return ("yes");
                    break;
                default:
                    return ("no");
                    break;
            }
        }
    </script>
Taking a closer look at the script you see the last function “displayWait”. There you could define on which buttons the ‘Please wait’ screen should be displayed. In current example the button has to have the text “Save” or “Save and Close”. On all other buttons the “Please wait” screen will not be displayed. Of course you should modify this function according to your needs.

Buttons in Ajax Update Panel

Add an Update Panel to your aspx page. Place your buttons in the Update-Panel. At least the buttons which should display the ‘Please wait’ screen need to be in the UpdatePanel, but you could of course also add other buttons etc. there.
<asp:UpdatePanel ID="PleaseWaitPanel" runat="server" RenderMode="Inline">
    <ContentTemplate>
       <asp:Button ID="Save" runat="server" Text="Save" OnClick="Save_Click" />
       <asp:Button ID="SaveClose" runat="server" Text="Save and Close" OnClick="SaveClose_Click" />
    </ContentTemplate>
</asp:UpdatePanel>

Aspx Controls

Add a Panel, Button and a ModalPopupExtender to your aspx page. The Panel will be displayed in the middle of the screen. The hidden button is necessary for the ModalPopupExtender as it needs a TargetControl.
<asp:Panel ID="PleaseWaitMessagePanel" runat="server" CssClass="modalPopup" Height="50px" Width="125px">
    Please wait<br />
    <img src="ajax-loader.gif" alt="Please wait" />

Image

Add an animated gif to your project. Check Ajaxload.info to create your own if you like, otherwise you might use this one: ajax-loader

Build

That’s it. Now build your application. Or maybe you want to download the example.

|
0

Play a Video from asp.Net application

Posted by Rajendra Prasad Panchati on Tuesday, August 10, 2010
Here is a code sample.
  1. Create a .aspx file in your site and delete the code-behind file . We need only a single .aspx file.
  2. Put the code below into the page.
  3. Run the site and load the page.
  4. Address the video URL in the TextBox and press the Play button.


 <%@ Page Language="C#" %>
<!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 btnPlay_Click(object sender, EventArgs e)
 {
  try
  {
   string mySourceUrl = this.TextBox1.Text;
   bool isFullSize = false;
   this.Literal1.Text = this.GetWmaObject(mySourceUrl, isFullSize);
  }
  catch (Exception ex)
  {
   this.Response.Write(ex.ToString());
  }
 }
 private string GetWmaObject(string sourceUrl, bool isFullSize)
 {
  string myObjectTag = "";
  sourceUrl = sourceUrl + "";
  sourceUrl = sourceUrl.Trim();
  if (sourceUrl.Length > 0)
  {
   //Continue.
  }
  else
  {
   throw new System.ArgumentNullException("sourceUrl");
  }
  
  string myWidthAndHeight = "";
  if (isFullSize)
  {
   myWidthAndHeight = "";
  }
  else
  {
   myWidthAndHeight = "width='640' height='480'";
  }
  myObjectTag = myObjectTag + "<object classid='CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95' id='player' " + myWidthAndHeight + " standby='Please wait while the object is loaded...'>";
  myObjectTag = myObjectTag + "<param name='url' value='" + sourceUrl + "' />";
  myObjectTag = myObjectTag + "<param name='src' value='" + sourceUrl + "' />";
  myObjectTag = myObjectTag + "<param name='AutoStart' value='true' />";
  myObjectTag = myObjectTag + "<param name='Balance' value='0' />"; //-100 is fully left, 100 is fully right.
  myObjectTag = myObjectTag + "<param name='CurrentPosition' value='0' />"; //Position in seconds when starting.
  myObjectTag = myObjectTag + "<param name='showcontrols' value='true' />"; //Show play/stop/pause controls.
  myObjectTag = myObjectTag + "<param name='enablecontextmenu' value='true' />"; //Allow right-click.
  myObjectTag = myObjectTag + "<param name='fullscreen' value='" + isFullSize.ToString() + "' />"; //Start in full screen or not.
  myObjectTag = myObjectTag + "<param name='mute' value='false' />";
  myObjectTag = myObjectTag + "<param name='PlayCount' value='1' />"; //Number of times the content will play.
  myObjectTag = myObjectTag + "<param name='rate' value='1.0' />"; //0.5=Slow, 1.0=Normal, 2.0=Fast
  myObjectTag = myObjectTag + "<param name='uimode' value='full' />"; // full, mini, custom, none, invisible
  myObjectTag = myObjectTag + "<param name='showdisplay' value='true' />"; //Show or hide the name of the file.
  myObjectTag = myObjectTag + "<param name='volume' value='50' />"; // 0=lowest, 100=highest
  myObjectTag = myObjectTag + "</object>";
  return myObjectTag;
 }
 
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
  <br />
  <br />
  <asp:literal id="Literal1" runat="server"></asp:literal>
  <br />
  <br />
  <asp:textbox id="TextBox1" runat="server" width="500px" height="50px" wrap="true" textmode="multiLine" 
readonly="false" >http://download.microsoft.com/download/8/3/6/836dd5f8-fa92-499f-8219-0d326f13bf18/hilo_data_final.wmv</asp:textbox>
  <br />
  <br />
  <asp:button id="btnPlay" runat="server" text="Play" onclick="btnPlay_Click" />
    </div>
    </form>
</body>
</html>

|
0

Menu Control

Posted by Rajendra Prasad Panchati on Tuesday, August 10, 2010
For Menu Controls U'll be needed UI Code & Style sheet given below.

UI Code:
    Place this piece of code in aspx/ascx file.
 
<ul class="cssMenu cssMenum" style="display: table; width: 150px;">
        <li class=" cssMenui" style="width: 150px;"><a class=" cssMenui" href="#" >
            <h2 style="text-align:center;">    Menu
                </h2>
            <![if gt IE 6]></a> <![endif]>
            <!--[if lte IE 6]><table><tr><td><![endif]-->
            <ul class=" cssMenum" style="margin-left: 148px !important; margin-left: 144px; margin-top: -20px;">
                <li class=" cssMenui">   <a class=" cssMenui" href="#"> Sub Menu1<![if
                    gt IE 6]> </a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->
                    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
                </li>
                <li class=" cssMenui"><a class=" cssMenui" href="#"> Sub Menu2<![if
                    gt IE 6]></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->
                    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
                </li>
                <li class=" cssMenui"><a class=" cssMenui" href="#"> Sub Menu3
                <![if gt IE 6]></a><![endif]><!--[if lte IE 6]><table><tr><td><![endif]-->
                    <!--[if lte IE 6]></td></tr></table></a><![endif]-->
                </li>
            </ul>
            <!--[if lte IE 6]></td></tr></table></a><![endif]-->
        </li>
</ul>
Style Sheet:
     Place this styles in a style sheet from your application.

/* CSS Document @charset "utf-8"; */
ul.cssMenu ul{display:none}
ul.cssMenu li:hover>ul{display:block}
ul.cssMenu ul{position: absolute;left:-1px;top:98%;}
ul.cssMenu ul ul{position: absolute;left:98%;top:-2px;}
ul.cssMenu,ul.cssMenu ul {
    margin:0px;
    list-style:none;
    padding:0px ;
    /*background-color:#000000;
    background-repeat:repeat;*/
    border-style:none;
}
ul.cssMenu table {border-collapse:collapse;}ul.cssMenu {
    display:block;
    zoom:1;
    position:absolute;
    z-index: 1000;
   
}
* HTML ul.cssMenu {position:absolute;}
ul.cssMenu ul{
    width:192px;
}
ul.cssMenu li {
    display:block;
    margin:0px 12px 0px 0px;
    font-size:0px;
}
ul.cssMenu a:active, ul.cssMenu a:focus {
outline-style:none;
}

ul.cssMenu a, ul.cssMenu li.dis a:hover, ul.cssMenu li.sep a:hover, ul.cssMenu li.sep a:visited {
    display:block;
    vertical-align:middle;
    /*background-color:#000000;*/
    border-width:0px;
    border-color:#000000;
    border-style:none;
    text-align:left;
    text-decoration:none;
    padding:0px;
    _padding-left:0;
    font:bold 12px ;
    color: #FFFFFF;
    text-decoration:none;
    cursor:pointer;
}
ul.cssMenu span{
    overflow:hidden;
}
ul.cssMenu li {
    float:left;
}
ul.cssMenu ul li {
    float:none;
}
ul.cssMenu ul a {
    text-align:left;
    /*white-space:nowrap;*/
}
ul.cssMenu li.sep{
    text-align:left;
    padding:0px;
    line-height:0;
    height:100%;
}
ul.cssMenu li.sep span{
    float:none;    padding-right:0;
    width:3px;
    height:100%;
    display:inline-block;
    background-color:#C0AF62;    background-image:none;}
ul.cssMenu ul li.sep span{
    width:100%;
    height:3px;
}
ul.cssMenu li:hover{
    position:relative;
}
ul.cssMenu li:hover>a{
    background-color:#EFEFEF;
    border-color:#4C99AB;
    border-style:none;
    font:normal 12px Verdana, Arial, Helvetica, sans-serif;
    color: #000000;
    text-decoration:none;
}
ul.cssMenu li a:hover{
    position:relative;
    background-color:#EFEFEF;
    border-color:#4C99AB;
    border-style:none;
    font:bold 12px Verdana, Arial, Helvetica, sans-serif;
    color: #000000;
    text-decoration:none;
}
ul.cssMenu li.dis a {
    color: #AAAAAA !important;
}
ul.cssMenu img {border: none;float:left;_float:none;margin-right:3px;width:16px;
height:16px;
}
ul.cssMenu ul img {width:16px;
height:16px;
}
ul.cssMenu img.over{display:none}
ul.cssMenu li.dis a:hover img.over{display:none !important}
ul.cssMenu li.dis a:hover img.def {display:inline !important}
ul.cssMenu li:hover > a img.def  {display:none}
ul.cssMenu li:hover > a img.over {display:inline}
ul.cssMenu a:hover img.over,ul.cssMenu a:hover ul img.def,ul.cssMenu a:hover a:hover ul img.def,ul.cssMenu a:hover a:hover img.over,ul.cssMenu a:hover a:hover a:hover img.over{display:inline}
ul.cssMenu a:hover img.def,ul.cssMenu a:hover ul img.over,ul.cssMenu a:hover a:hover ul img.over,ul.cssMenu a:hover a:hover img.def,ul.cssMenu a:hover a:hover a:hover img.def{display:none}
ul.cssMenu a:hover ul,ul.cssMenu a:hover a:hover ul{display:block}
ul.cssMenu a:hover ul ul{display:none}
ul.cssMenu span{
    display:block;
    background-image:url(default.files/arrowmain.gif);
    background-position:right center;
    background-repeat: no-repeat;
   padding-right:11px;}
ul.cssMenu li:hover>a>span{    background-image:url(default.files/arrowmaino.gif);
}
ul.cssMenu a:hover span{    _background-image:url(default.files/arrowmaino.gif)}
ul.cssMenu ul span,ul.cssMenu a:hover table span{background-image:url(default.files/arrowsub.gif)}
ul.cssMenu ul li:hover > a span{    background-image:url(default.files/arrowsubo.gif);}
ul.cssMenu table a:hover span,ul.cssMenu table a:hover a:hover span{background-image:url(default.files/arrowsubo.gif)}
ul.cssMenu table a:hover table span{background-image:url(default.files/arrowsub.gif)}
/*a:link {color:#FFFFFF}       unvisited link */
/*a:visited {color:#FFFFFF}   visited link */
/*a:hover {color:#FFFFFF}   mouse over link */
/*a:active {color:#FFFFFF}   selected link */
ul.cssMenu a, ul.cssMenu li.dis a:hover, ul.cssMenu li.sep a:hover, ul.cssMenu li.sep a:visited{color:#FFFFFF;}
ul.cssMenu a, ul.cssMenu li a:hover, ul.cssMenu li a:hover, ul.cssMenu li a:visited{color:#FFFFFF;font-size:12px; font-weight:bold;font-family: Verdana, Arial, Helvetica, sans-serif;}
ul.cssMenu li a:hover {color:#000000;font-size:12px;font-weight:bold;font-family: Verdana, Arial, Helvetica, sans-serif;}

|
0

IIS Redirects - 301 , 302

Posted by Rajendra Prasad Panchati on Friday, July 23, 2010

Microsoft's Internet Information Server ( MS IIS ) is very different from Apache, and you need to handle redirects on it differently.
Although you can use the popular FrontPage web development software with Apache + FP extensions, most people who use FrontPage prefer to use IIS. Also, Microsoft's .NET and ASP development platforms usually work best on MS IIS (no surprise there).
Definitions for Terms used in this Article

Detailed Information

Overview

What you are trying to accomplish here is to have one resource (either a page or an entire site) redirect a visitor to a completely different page or site, and while doing so tell the visitor's browser that the redirect is either permanent (301) or temporary (302).
Therefore you need to do three things:
  1. Have 2 resources - one source page or website, and one destination page or website.
  2. When an attempt to access the source resource is made, IIS transfers the visitor to the destination instead.
  3. During the transfer, IIS reports to the visitor that a redirect is happening and it's either temporary or permanent.
The good news is that IIS has always supported this, and you can use it's control panel to make the redirect.

Administrator Mode - Redirecting a Domain

If you can log into the Windows 2000 (or higher) server and access the desktop, then choose:
Start > Programs > Administrative Tools > Internet Services Manager
Now choose the server running the site you want to forward. Remember you need 2 sites - one to forward FROM and one to forward TO. These can be on the same, or separate servers.

Right click on the site you want to redirect FROM and choose Properties > Home Directory

You will see the following:


The default is the first choice, "A directory located on this computer". Change it to "A redirection to a URL" and type in the new URL.
If you want it to be a 301, then be sure to check ON the choice for "A permanent redirection for this resource". If you want it to be a 302, leave the choice checked OFF.

Administrator Mode - Redirecting an Individual Page

If you can log into the Windows 2000 (or higher) server and access the desktop, then choose:
Start > Programs > Administrative Tools > Internet Services Manager
Now choose the server running the site you want to forward. Choose the site with the webpage you want to forward in it, then right click on the it and choose "Properties".

You will see the following:


The default is the first choice, "The designated file". Change it to "A redirection to a URL" and type in the new URL.
If you want it to be a 301, then be sure to check ON the choice for "A permanent redirection for this resource". If you want it to be a 302, leave the choice checked OFF.
If you don't control the IIS server, ask the admin to do the above. Done.

Passing on Variables or a Query String During IIS Redirects

Let's say that you want to pass on some variables, for example, you wanted to redirect an ASP site that accepted arguments for some pages and pass those same arguments on to the same pages at the new site.
In this case, in the "Redirect to:" box, enter the domain you wish to move to (no trailing slash), plus $S$Q .
For example:
http://www.newdomain.com$S$Q
Next, check the options that state the client will be sent to "The exact URL entered above", as well as "A permanent redirection for this resource" (if you want it to be a 301). Done.
What does this $S$Q do? These are tags that IIS will automatically replace - $S will be replaced with the subdirectory location (such as /shopping/cart.aspx) and $Q will be replaced with the querystring (such as ?id=Blue).
Server Variable Function Example
$P Passes parameters that were passed to the URL to the new URL. If the request contains parameters such as http://www.oldsite.com/cart.asp?id=Blue , then $P would represent all the values after the question mark in the URL, example $P would equal id=Blue (no question mark).
$Q Passes the parameters including the question mark. This is the same as $P but includes the question mark or query string. So $P would equal ?id=Blue
$S Passes the matching suffix of the URL to the new URL. If the request is for http://www.oldsite.com/shopping/cart.asp, then $S represents /cart.asp. If the request was for http://www.oldsite.com/shopping then the value of $S would be /shopping
$V Removes the server name from the original request. If the request is for http://www.oldsite.com/shopping/cart.asp then $V would contain everything after the server name, eg: /shopping/cart.asp.
* Wildcard symbol used for replacement. Let's say you want to redirect all requests for html pages to a single asp page - you could do so in the following way: *;*.htm;page.asp

This works for both Site Redirects and Individual Page Redirects.

Common Scenarios

I Just Want To Switch Domains!

This is actually pretty straightforward. You can tweak things to get exactly what you need with the variables above, but the following will work for the most common setups:
http://www.newdomain.com$V$Q
Do NOT add a trailing slash "/" at the end of the domain name!
Make sure you check:
  • The exact URL entered above
  • A permanent redirection for this resource
Done! This will send everything after the old domain name to the new domain name, including variables. You need to do is make sure that the new website is set up exactly the same as the old one and that all you are doing is changing domain names.

Non-WWW to WWW Redirect for IIS

When you set up a site in IIS, usually you set up the site with a domain name and add the domain name with both versions, www and non-www, to the host headers for the account. This creates a potential duplication issue, though.
The better way to do this is to actually create 2 accounts - one with the www version and one without. Then you put the website in your preferred version and a single page in the other. Normally, you would then treat this as if you were switching domains (above), with the 2 domains being the www and the non-www versions.
Another method, for those that don't have direct access to the control panel (common with many ISP's/ hosts), is to put your entire website in the www account and then a single page in the non-www account. Then you would put the following code in the default page in the account with the single page (i.e. the one you are redirecting):
< %@ Language=VBScript %>
< %
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", http://www.example.com
%>

What about Parameters?

If you do a non-www to www redirect for MS Internet Information Services (IIS) and have parameters that need to be passed on, then do the following (Thanks to Chris Hirst for testing this):
  1. Do the above non-WWW to WWW redirect
  2. Make double sure that you do NOT have a trailing slash at the end of the domain (http://www.newdomain.com$V$Q, NOT http://www.newdomain.com/$V$Q)
  3. As with all these redirects, make sure that you check "The exact URL entered above"

Don't Have Administrator or Desktop Access?

If possible, ask the Administrator for the site to perform the above steps. If you can't, you need to use ASP or .NET scripting on-page to do redirects.

Conclusion

IIS is a powerful and easy to use web hosting platform. If you have access to the Admin panel you can accomplish basic tasks (like simple redirection) easily and quickly. If you don't have access (and don't want to switch hosts) then you will have to use redirection scripting to accomplish this. You'll learn more about that in the Redirects Using On-Page Scripting and Headers section.

Reference: http://www.mcanerin.com/en/articles/301-redirect-iis.asp

|

About Me