본문 바로가기

닷넷관련/ASP.NET WEBFORM

RedirectButton - Redirect Users With the Click of a Button



1. Exploring the RedirectButton Control's Functionality


<cc1:RedirectButton runat="server" ID="btnToGoogle" 
               RedirectUrl="http://www.google.com/" 
               Text="And We're Off to Google!"
 />


<input type="button" name="btnToGoogle" value="And We're Off to Google!" id="btnToGoogle"
       onclick="skm_Redirect('http://www.google.com/', '');" />


2. Sending User Input in the Querystring

Search: <asp:TextBox ID="txtSearchQuery" runat="server"></asp:TextBox><br />

<cc1:RedirectButton runat="server" ID="btnSearchRedirectButton" 
               AssociatedControlId="txtSearchQuery" 
               QueryStringParameterName="query" 
               RedirectUrl="~/SearchResults.aspx"

               Text="Go!" />

<input type="button" name="btnSearchRedirectButton" value="Go!" id="btnSearchRedirectButton" 
      onclick="skm_Redirect('SearchResults.aspx?q={AssocCtrlValue}', 'txtSearchQueryRedirectButton');" />


3. RedirectButton control adds JavaScript to the associated TextBox 
    so that when the user presses the Enter key it "clicks" the associated button.

Search Google: <asp:TextBox ID="txtSearchGoogle" runat="server"></asp:TextBox>

<cc1:RedirectButton runat="server" ID="btnSearchGoog" 
               AssociatedControlId="txtSearchGoogle" 
               QueryStringParameterName="q" 
               RedirectUrl="http://www.google.com/search" 
               Text="Go!" />



4. Adding the skmControls2 Library to Your Web Application

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