5 Replies - 8624 Views - Last Post: 24 July 2011 - 11:17 PM Rate Topic: -----

#1 November-06   User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Problem in displaying usercontrol as popup

Posted 24 July 2011 - 12:38 AM

I am trying to display a popup WebUserControl in my webpage.

My .aspx codes are these...
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="index.aspx.vb" Inherits="index" %>

<%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>
    
<%@ Register Src="~/WebUserControls/ctl_Popup.ascx" TagName="ctl_Popup" TagPrefix="uc"%>

<!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">
    <asp:ScriptManager ID="scrpt" runat="server"></asp:ScriptManager>
    <div>

                <asp:Button ID="btnSample" Text="Sample" runat="server" />

        
        <div id="divPopup" style="display:none;">
            <div style="display:block; width:200px; height:200px;">
                <asp:UpdatePanel ID="updSample" runat="server">
                    <ContentTemplate>
                        <uc:ctl_Popup ID="ctlPopup" runat="server" />
                    </ContentTemplate>
                </asp:UpdatePanel>
            /div>
            
        </div>
    </div>
    </form>
</body>
</html>



Now, to call my usercontrol, in my .vb, I have this...

Imports System.Web
Imports System.Web.UI

Partial Class index
    Inherits System.Web.UI.Page

    Protected Sub btnSample_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSample.Click
        ctlPopup.Initialize() 'Calls the Initialize Subroutine in the usercontrol
        ScriptManager.RegisterStartupScript(Me, Me.GetType(), "show_popup", "revealModal('divPopup');", True)
    End Sub
End Class



My problem is that nothing shows when I click my sample button. When I had my OJT, all we do to call the popup are these. Am I missing something? Should I be using javascript instead? I do not know anything about javascript though.

Is This A Good Question/Topic? 0
  • +

Replies To: Problem in displaying usercontrol as popup

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14507
  • View blog
  • Posts: 58,158
  • Joined: 12-June 08

Re: Problem in displaying usercontrol as popup

Posted 24 July 2011 - 09:45 AM

ASP.NET question - so moved accordingly.

I would say look into the MS Ajax extender controls.
http://ajaxcontrolto...ases/view/65800

They have a great 'popup extender'.
http://www.asp.net/a.../act_Popup.ashx

http://www.asp.net/a..._tutorials.ashx
Was This Post Helpful? 0
  • +
  • -

#3 Nakor   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: Problem in displaying usercontrol as popup

Posted 24 July 2011 - 12:19 PM

quick question, where is the javascript function revealModal defined at? I'm not seeing any references to a javascript file in the code you've provided. Is that in the user control code?

You're using the function here
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "show_popup", "revealModal('divPopup');", True)



also you don't have the button's Click property set to the button click action defined in the code behind.

<asp:Button ID="btnSample" Text="Sample" runat="server" />



And as modi123_1 said, the AjaxControlToolkit contains a very easy to use modal popup extender. You could also use a jQuery dialog as a popup.

This post has been edited by Nakor: 24 July 2011 - 12:24 PM

Was This Post Helpful? 1
  • +
  • -

#4 November-06   User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Re: Problem in displaying usercontrol as popup

Posted 24 July 2011 - 08:56 PM

Thanks for the reply. Do you know where I can get reference with simple guide on how to construct the method to create popup in javascript?

This post has been edited by November-06: 24 July 2011 - 08:56 PM

Was This Post Helpful? 0
  • +
  • -

#5 Nakor   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: Problem in displaying usercontrol as popup

Posted 24 July 2011 - 09:56 PM

Did you want to create the method all on your own, or did you want to use a library like JQuery? Or did you want to make use of the AjaxControlToolkit's popup extender? If you're just needing to hide and display a div element you could just use javascript to set the display style on the div.

// hide element
document.getElementById('id').style.display = 'none';

// show element
document.getElementById('id').style.display = '';



or if you are using JQuery you have a few more options, but the most basic way would be

 
// hide element
$('#id').hide();

// show element
$('#id').show();



syntax may be slightly off since I'm just working from memory on the plain javascript version, but it should be close.
Was This Post Helpful? 1
  • +
  • -

#6 November-06   User is offline

  • D.I.C Regular

Reputation: 53
  • View blog
  • Posts: 482
  • Joined: 04-January 11

Re: Problem in displaying usercontrol as popup

Posted 24 July 2011 - 11:17 PM

Thanks. I have made it work. Thanks for all your suggestion.

I'll try to learn more on the use of javascript.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1