C# .NET - asp.net in c#

Asked By monica
29-May-11 03:14 PM
how to create pops in asp.net.....i want pops ups like registration form appears when we click on a register link....i am not able to create this kind of pops....so plzz if anyone know this then plzz let me know....my email id is monikasoniya17@gmail.com
  Mihir Soni replied to monica
29-May-11 03:26 PM
Hello,

for tha you can make a best use of ajax modalpopupextender.

Download ajax toolkit from following link

http://www.asp.net/ajax

Just follow the steps given in above link and you will be able to poup the window for registration

just put your all controls in asp.net panel and then give popuid to modelpopup extnder

Hope this helps you

thank you
  dipa ahuja replied to monica
29-May-11 03:37 PM
You can do so by using the modalpopup Extender.. its very easy to create..
here i am giving you the simple example:

Untitled document
 
  <style type="text/css">
   .modalBackground
   {
   background-color: #CCCCFF;
   filter: alpha(opacity=40);
   opacity: 0.5;
   }
   .ModalWindow
   {
   border: solid1px#c0c0c0;
   background-color: Maroon;
   padding: 0px10px10px10px;
   position: absolute;
   top: -1000px;
   }
 </style>
 
 <cc1:ScriptManager ID="ScriptManager1" runat="server">
 </cc1:ScriptManager>
 <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
 
TargetControlID="lnkPopup"
PopupControlID="panEdit" BackgroundCssClass="modalBackground"
 
CancelControlID="btnCancel"
 
   PopupDragHandleControlID="panEdit">
 </cc1:ModalPopupExtender>
 <asp:Panel ID="panEdit" runat="server" Height="200px" Width="400px" CssClass="ModalWindow">
   <table runat="server">
   <tr>
     <td class="formtext" style="height: 23px; width: 150px;" align="left">
     Old PassWord:
     </td>
     <td>
     <asp:TextBox ID="txtFields1" runat="server"></asp:TextBox>
     </td>
   </tr>
   <tr>
     <td class="formtext" style="height: 23px; width: 150px;" align="left">
     New PassWord:
     </td>
     <td>
     <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
     </td>
   </tr>
   </table>
   <br />
   <asp:Button ID="Button1" runat="server" Text="Change" />
   <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
 </asp:Panel>
 <a id="lnkPopup" runat="server" href="#">Change Password</a>
 
  Riley K replied to monica
29-May-11 09:12 PM
To used AJAX first you have to place a script manager, then the modalpopupextender from toolkit

the code will look like this

<asp:scriptmanager id="ScriptManager1" runat="server">
</asp:scriptmanager>
 
<asp:button id="Button1" runat="server" text="Button" />
 
<cc1:modalpopupextender id="ModalPopupExtender1" runat="server"
  cancelcontrolid="btnCancel" okcontrolid="btnOkay"
  targetcontrolid="Button1" popupcontrolid="Panel1"
  popupdraghandlecontrolid="PopupHeader" drag="true"
  backgroundcssclass="ModalPopupBG">
</cc1:modalpopupextender>
 
<asp:panel id="Panel1" style="display: none" runat="server">
  <div class="HellowWorldPopup">
        <div class="PopupHeader" id="PopupHeader">Header</div>
        <div class="PopupBody">
          <p>This is a simple modal dialog</p>
        </div>
        <div class="Controls">
          <input id="btnOkay" type="button" value="Done" />
          <input id="btnCancel" type="button" value="Cancel" />
    </div>
    </div>
</asp:panel>


In the above code in the modal popup see the popupcontrolID property, in this property we will specify the
panel that we want to display..


Place control in Div or ASP.NET panel in the page that you want to display as a modal dialog. Give an id of the panel and put done and cancel button in the panel. Do add a header div in the panel, which will serve as a header of the popup. Last of all, add a target link or button anywhere in the page except inside the div that you want to show as a modal popup. Clicking on the link for the popup will make the popup display.

To show the popup, we are going to use $find('behaviourIDofModal').show(); and to hide the modal, we are going to use $fin('behaviourIDofTheModal').hide();. Alternately we can auto raise the click JavaScript event of the targetcontrolid using JavaScript to show the popup and also raise the click event of the cancel control of the popup to hide the popup again.

<script language="javascript" type="text/javascript">
  function pageLoad() {
    ShowPopup();
    setTimeout(HidePopup, 2000);
  }
 
  function ShowPopup() {
    $find('modalpopup').show();
    //$get('Button1').click();
  }
 
  function HidePopup() {
    $find('modalpopup').hide();
    //$get('btnCancel').click();
  }
</script>
  James H replied to monica
29-May-11 11:22 PM
Hi for Getting Modal Pop ups in asp.net please use Ajax Modal Pop Up like this 
In this example i'm going to describe how to implement Ajax Modal PopUp Extender on Mouse Over in ASP.NET using C# and VB.NET

For this to work u need to download and installhttp://ajaxcontroltoolkit.codeplex.com/



Create a new website in visual studio and write html markup of aspx page as shown below.



Put AjaxControlToolkit.dll in BIN folder and register assembly in page directive of ur aspx page.

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

Now in Head section of page add this javascript method 

<script type="text/javascript">

function MouseHover() 
{
$find("modelPopupExtender1").show();
}

</script>

The complete HTML source of page will look like this 
<%@ Page Language="C#" AutoEventWireup="true"  
CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" 
Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

<!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>Ajax Model PopUp Extender With MouseOver Example</title>
<link href="StyleSheet.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript">

        function MouseHover() 
     {
         $find("modelPopupExtender1").show();
     }
  
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
<ajaxToolkit:ToolkitScriptManager ID="toolKitScriptManager1" 
                                  runat="server">
</ajaxToolkit:ToolkitScriptManager>    
<p style="background-color: #9999FF; width: 95%;">
     
Example of using a ModalPopupExtender with with Mouse Over
<br/></p><br/>
Hover over the hyperlink 
<asp:HyperLink ID="HyperLink1" runat="server" 
               onmouseover="MouseHover();" 
               Font-Underline="True" ForeColor="Blue">
<b>Mouse Over Here to Open PopUp</b>
</asp:HyperLink> to open pop up
            
<ajaxToolkit:ModalPopupExtender runat="server" 
                   BehaviorID="modelPopupExtender1" 
                   TargetControlID="HyperLink1"
                   PopupControlID="popUpPanel" 
                   OkControlID="btnOk" 
                   BackgroundCssClass="modalBackground" >
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="popUpPanel" runat="server" 
           CssClass="confirm-dialog">
<div class="inner">
<h2>
Thanks For Visiting This Site</h2>
<div class="base">
<asp:Button ID="btnOk" runat="server" Text="Ok"/>
<asp:LinkButton ID="LinkButton1" runat="server" 
                CssClass="close" 
OnClientClick="$find('modelPopupExtender1').hide(); return false;"/>
</div></div>
</asp:Panel>
            
                  
            
    </div>
    </form>
</body>
</html>

Please refer this link
http://forums.asp.net/p/1383041/2931382.aspx
http://www.codeproject.com/KB/aspnet/Modal_Dialog.aspx

Hope this will help you :-)
  TSN ... replied to monica
29-May-11 11:22 PM
hi..

I could provide the exact solution for your requirement but here is the solution which would guide you in solving your problem...

here is the control iam going to popup is the Login just make changes to that page adding controls for the registration and here follows the example...

Create a new ASCX  file called PopupLoginControl.ascx and copy paste the following markup tags.
 
<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”ajaxtoolkit” %>
 
<asp:Button ID=”btnShowPopup” runat=”server” Style=”display: none” />
 
<ajaxtoolkit:ModalPopupExtender BackgroundCssClass=”modalBackground”
CancelControlID=”btnClose” runat=”server” PopupControlID=”Panel1″ ID=”ModalPopupExtender1″
TargetControlID=”btnShowPopup” />
 
<asp:Panel ID=”Panel1″ runat=”server” CssClass=”modalPopup” DefaultButton=”btnOk”>
<table width=”100%” border=”0″ cellpadding=”2″ cellspacing=”5″>
<tr>
<td style=”width:35%;padding-top:50px;”>
</td>
<td>
<asp:Label id=”labMsg” runat=”server” />
</td>
</tr>
<tr>
<td align=”right” valign=”middle”>
<strong>Email Id :</strong>
</td>
<td>
 <asp:TextBox ID=”txtLogin” runat=”server”></asp:TextBox>
</td>
</tr>
<tr>
<td align=”right” valign=”middle”>
<strong>Password :</strong>
</td>
<td>
 <asp:TextBox ID=”txtPassword” runat=”server” TextMode=”Password”></asp:TextBox>
</td>
</tr>
<tr>
<td>
 
</td>
<td>
<asp:Button ID=”btnOk” OnClick=”Login” runat=”server” Text=”Sign In” />
<asp:Button ID=”btnClose” runat=”server” Text=”Cancel” />
</td>
</tr>
</table>
</asp:Panel>
 
PopupLoginControl.ascx.Cs
 
 public event EventHandler LoginStatus;
 bool status;
 
 public Boolean IsLogin
 {
 get { return status; }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
 
 }
 protected void Login(object sender, EventArgs e)
 {
 labMsg.Text = string.Empty;
 
 ModalPopupExtender1.Show(); //show pop up window
 
 if (LoginStatus != null)
 {
 if (txtLogin.Text.Equals("admin") && txtPassword.Text.Equals("admin"))
 {
 status = true;
 
 LoginStatus(this, EventArgs.Empty); //event get fired here.
 
 ModalPopupExtender1.Hide(); //hide pop up window once the user logged in successfully.
 }
 else
 {
 labMsg.Text = "<font color=red>Sorry user name and password could not find</font>";
 }
 }
 }
 public void EnableModelDialog(bool visibility)
 {
 if (visibility)
 {
 ModalPopupExtender1.Show();
 }
 else
 {
 ModalPopupExtender1.Hide();
 }
 }
 
LoginTest.aspx page(Markup)
 
<%@ Register Src=”PopupLoginControl.ascx” TagName=”PopupLoginControl” TagPrefix=”uc1″ %>
 
<style type=”text/css”>
.modalBackground
{
background-color: Gray;
filter: alpha(opacity=70);
opacity: 0.7;
}
.modalPopup
{
background-color: White;
height: 250px;
width:500px;
text-align:left;
}
</style>
 
<form id=”form1″ runat=”server”>
 
<asp:ScriptManager ID=”Scriptmanager1″ runat=”server” />
 
<asp:UpdatePanel ID=”UpdatePanel1″ runat=”server”>
 
<ContentTemplate>
 
<asp:LinkButton ID=”lnkWriteMessage” runat=”server” OnClick=”ShowMessage”>Write Comments</asp:LinkButton>
 
<uc1:PopupLoginControl ID=”PopupLoginControl1″  OnLoginStatus=”PopupLoginCntl_Completed”
Visible=”false” runat=”server” />
 
<asp:Panel ID=”divComments” Visible=”false” runat=”server”>
 
<table width=”50%”>
<tr>
<td>
<textarea id=”txtComments” rows=”10″ cols=”60″></textarea>
</td>
</tr>
<tr>
<td>
<asp:Button id=”btnSave” runat=”server” Text=” Save ” onclick=”btnSave_Click” />
</td>
</tr>
</table>
 
</asp:Panel>
 
</ContentTemplate>
 
</asp:UpdatePanel>
 
</form>
 
LoginTest.aspx page(CSharp)
 
protected void ShowMessage(object sender, EventArgs e)
 {
 PopupLoginControl1.Visible = true;
 PopupLoginControl1.EnableModelDialog(true);
 }
 
//method get called when the usercontrol event get fired
 protected void PopupLoginCntl_Completed(object sender, EventArgs e)
 {
 if (PopupLoginControl1.IsLogin)
 {
 divComments.Visible = true;
 }
 else
 {
 divComments.Visible = false;
 }
 }
 
 protected void btnSave_Click(object sender, EventArgs e)
 {
//save your comments here.
 }

For more information about the user control event bubbling please visit the following links

http://asp.net-tutorials.com/user-controls/events/

http://codebetter.com/blogs/brendan.tompkins/archive/2004/10/06/Easily-Raise-Events-From-ASP.NET-ASCX-User-Controls.aspx

http://odetocode.com/code/94.aspx
  James H replied to monica
29-May-11 11:22 PM

jQuery Modal Form Dialog is your way to go here. I made a test app doing what you wanted with it and it worked well.

Markup for your ASPX page:

<div id="dialog" title="Please Login">
        <asp:Login ID="login" runat="server" />
</div>

Javascript needed for the page:

$(document).ready(function() {
$("#dialog").dialog({
    bgiframe: true,
    autoOpen: false,
    height: 300,
    modal: true,
    buttons: {
        Cancel: function() {
            $(this).dialog("close");
        }
    },
    close: function() {
        allFields.val("").removeClass("ui-state-error");
    }
});

var isAuthenticated = $("#isAuthenticated").val();
if (isAuthenticated && isAuthenticated == "false") {
    // Display the modal dialog.
    $("#dialog").dialog("open");
}});

Code behind I used on the aspx page:

ClientScript.RegisterHiddenField("isAuthenticated", "false");

You would give it true or false, depending on if the user was authenticated, so the javascript would know to display the login or not.

Now about the security. The login wouldn't be done by the javascript because the user would hit the button on that login page and it would post back to the server like normal. If you wanted to use ajax, you would have to check out the jQuery http://docs.jquery.com/Ajax method.

  Vickey F replied to monica
29-May-11 11:39 PM

If you want to show modal popup then use jquery popup.

after adding jqueryui plugin you can use it.

like this-

<script>
 $(function() {
  $( "#dialog" ).dialog();
 });
</script>

<div id="dialog" title="Basic dialog">hi
</div>

FOR EXAMPLE FOLLOW THIS

-http://jqueryui.com/demos/dialog/

Create New Account
help
code that for a module that prevents csrf attacks by attaching a token to each page. The code is in C#. Can ayone change this to vb for me. I have IHttpModule { #region IHttpModule members public void Dispose() { } public void Init(HttpApplication context) { context.PreSendRequestHeaders + = new EventHandler(PreSendRequestHeaders); context.PreRequestHandlerExecute + = new EventHandler(PreRequestHandlerExecute); } #endregion private static void PreSendRequestHeaders(object source, EventArgs args) { } HttpApplication application = (HttpApplication)source; HttpContext source, EventArgs eventargs) { HttpApplication application = (HttpApplication)source; HttpContext context = application.Context; if (context.Handler ! = null) { Page page = context.Handler as Page; if(page ! = null) { page.PreRender + = PagePreRender; { } } private static void PagePreRender(object source, EventArgs eventArgs) { Page page = source as Page
a gridview by using single database table? Explain with an example? Hi use this code <%@ Page Language = "C#" AutoEventWireup = "true" CodeFile = "DataRelation.aspx.cs" Inherits = "DataRelation" %> <%@ Import Namespace = "System.Data" %> <! DOCTYPE transitional.dtd" > < html xmlns = "http: / / www.w3.org / 1999 / xhtml" > < head runat = "server" > < title > Untitled Page < / title > < / head > < body > < form id = "form1" runat = "server" > < div > < asp:GridView ID = "GridView1" runat = "server UI.WebControls.WebParts; using System.Web.UI.HtmlControls; public partial class DataRelation : System.Web.UI.Page { protected void Page_Load( object sender, EventArgs e) { if (!IsPostBack) { GridView1.DataSource = CreateDS().Tables[ "Company" ]; GridView1 _loadControlMode = LoadControlModes.Template; / / / <summary> / / / Specifies whether the template shall be loaded as a template using Page.LoadTemplate / / / or as a UserControl using Page.LoadControl / / / < / summary> [DefaultValue(LoadControlModes.Template), Category("HierarGrid")] public LoadControlModes LoadControlMode { get { return _loadControlMode; } set { _loadControlMode new Panel(); drPanel.ID = panelName; panel.Controls.Add(drPanel); if(LoadControlMode = = LoadControlModes.Template) { ITemplate template = Page.LoadTemplate(templateFilename); template.InstantiateIn(drPanel); drPanel.Controls[0].ID = templateName; } else { Control template = Page.LoadControl(templateFilename); template.ID = templateName; drPanel.Controls.Add(template); } return drPanel; } / / / <summary> / / / Overridden to render name = "e"> < / param> protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); / / register on the page that LoadPostData is being called Page.RegisterRequiresPostBack(this); / / specifies the name of the hidden field
frames navigation .NET Framework I'm using frames on my home page like this: frame frame frame frame frame frame frame page page frame page page frame page page frame page page frame page page frame page page frame page page frame page page How do
msg box public static void ShowAlertMessage( string error) { Page page = HttpContext .Current.Handler as Page ; if (page ! = null ) { error = error.Replace( "'" , " \ '" ); ScriptManager .RegisterStartupScript(page, page.GetType(), "err_msg" , "alert('" + error + "');" , true ); } } public static void ShowAlertMessage( string error) { Page page = HttpContext .Current.Handler as Page ; if (page ! = null ) { error = error.Replace( "'" , " \ '" ); ScriptManager .RegisterStartupScript(page, page