Link to home
Start Free TrialLog in
Avatar of cmushaun
cmushaunFlag for United States of America

asked on

maintain js/div popup and button click / postback ASP.net

I have a div class that I am displaying as a javascript popup. This displays fine, but I need to be able to post back to the server without the popup closing, and the second I click the submit button, the popup disapears.  See my attached code (sorry it's bulky--just didn't want to cut out too much)
<form class="create_blurp_form" method="post" action="" id="respond" >
                            	<table cellpadding="0" cellspacing="0" border="0">
                                	<tr style="padding-bottom:7px;">
                                    	<td width="90"><asp:Label ID="nameLabel" runat="server" Text="Name:" /></td>

                                        <td width="275">
                                            <asp:TextBox ID="TextBox2" class="create_blurp_form_txt required"  runat="server"</asp:TextBox>
                                        </td>
                                        <td>
                                        	<div class="blurb_alert_right" id="blub_respond_username"  >
                                                <div class="blurb_alert">
                                                </div>
                                                <div class="blurb_alert_left"></div>
                                            </div>

                                        </td>
                                    </tr>
                                    <tr>
                                    	<td><asp:Label ID="ageLabel" runat="server" Text="Age:" /></td>
                                        <td>
                                            <asp:TextBox ID="TextBox3" style="width:80px;" runat="server"></asp:TextBox>
                                        </td>
                                        <td>

                                        	<div class="blurb_alert_right" id="blub_respond_age" >
                                                <div class="blurb_alert">
                                                    </div>
                                                <div class="blurb_alert_left"></div>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                    	<td><asp:Label ID="blurbTextLabel" runat="server" Text="Blurb Text:" /></td>

                                        <td>
                                                 <asp:TextBox ID="BlurbText" runat="server" Text="blurb text should be here" 
                                                Enabled="false" style="width:265px; height:90px; margin-bottom:7px;" cols="25" rows="10" TextMode="MultiLine" ></asp:TextBox>
                                        </td>
                                        <td></td>
                                    </tr>
                                    <tr>

                                    	<td></td>
                                        <td>
                                        <asp:TextBox ID="contactMeText" runat="server" MaxLength="100"
                        TextMode="MultiLine" style="width:265px; height:90px; margin-bottom:7px;" cols="25" rows="10"></asp:TextBox>
                                       </td>
                                        <td>
                                        	<div class="blurb_alert_right" id="blub_respond_interested">
                                                <div class="blurb_alert">
	                                      </div>
                                                <div class="blurb_alert_left"></div>

                                            </div>
                                        </td>
                                    </tr>
                                </table>
                                <p style=" border-bottom: 1px solid #979899; height:1px;"></p>
                               <asp:Button ID="RespondButton" runat="server" Text="Respond" 
                onclick="RespondButton_Click" ValidationGroup="responseGroup" />
                               </form>

Open in new window

Avatar of Alfred A.
Alfred A.
Flag of Australia image

Hi,

Try using UpdatePanel to prevent popup from closing.
Avatar of cmushaun

ASKER

Just at first couple trys with UpdatePanel    ... I'm getting a bunch of errors about how tables and forms aren't valid public properties of update panel
ASKER CERTIFIED SOLUTION
Avatar of Member_2_4913559
Member_2_4913559
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of himabindu
himabindu

We have an option for creating modal popup control in Ajax extensions tool box.

But the popup appears on firing an event like on clicking any button or linkbutton.

You can check this website for your reference

http://www.codeproject.com/KB/ajax/ASPModalInAction.aspx
Is anyone able to provide an example that I could try?

Thanks,
Mike
Not having your CSS or Javascript to see how your popup/modal/thing interacts I can make a simple sample just showing and hiding your table. When you click the Respond button the table is still showing because the JS function is called after the postback.
.ASPX PAGE (sample)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default7.aspx.cs" Inherits="Default7" %>

<!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>Untitled Page</title>
    <script type="text/javascript">
		
		function showTable()
		{
			document.getElementById('ImATableAlright').style.display = 'block';
		}
    
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <a href="http://www.google.com" onclick="showTable(); return false;">Show Table</a>
	<table id="ImATableAlright" cellpadding="0" cellspacing="0" border="0" style="display:none;">
		<tr style="padding-bottom: 7px;">
			<td width="90">
				<asp:Label ID="nameLabel" runat="server" Text="Name:" />
			</td>
			<td width="275">
				<asp:TextBox ID="TextBox2" class="create_blurp_form_txt required" runat="server"></asp:TextBox>
			</td>
			<td>
				<div class="blurb_alert_right" id="blub_respond_username">
					<div class="blurb_alert">
					</div>
					<div class="blurb_alert_left">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<asp:Label ID="ageLabel" runat="server" Text="Age:" />
			</td>
			<td>
				<asp:TextBox ID="TextBox3" Style="width: 80px;" runat="server"></asp:TextBox>
			</td>
			<td>
				<div class="blurb_alert_right" id="blub_respond_age">
					<div class="blurb_alert">
					</div>
					<div class="blurb_alert_left">
					</div>
				</div>
			</td>
		</tr>
		<tr>
			<td>
				<asp:Label ID="blurbTextLabel" runat="server" Text="Blurb Text:" />
			</td>
			<td>
				<asp:TextBox ID="BlurbText" runat="server" Text="blurb text should be here" Enabled="false"
					Style="width: 265px; height: 90px; margin-bottom: 7px;" cols="25" Rows="10" TextMode="MultiLine"></asp:TextBox>
			</td>
			<td>
			</td>
		</tr>
		<tr>
			<td>
			</td>
			<td>
				<asp:TextBox ID="contactMeText" runat="server" MaxLength="100" TextMode="MultiLine"
					Style="width: 265px; height: 90px; margin-bottom: 7px;" cols="25" Rows="10"></asp:TextBox>
			</td>
			<td>
				<div class="blurb_alert_right" id="blub_respond_interested">
					<div class="blurb_alert">
					</div>
					<div class="blurb_alert_left">
					</div>
				</div>
			</td>
		</tr>
	</table>
	<p style="border-bottom: 1px solid #979899; height: 1px;">
	</p>
	<asp:Button ID="RespondButton" runat="server" Text="Respond" OnClick="RespondButton_Click"
		ValidationGroup="responseGroup" />
    </form>
</body>
</html>



************************************

.ASPX.CS (CODE BEHIND)
NOTE: The actual call to RegisterStartupScript is identical is VB and C# except for the keyword "this" would be changed to "Me". You didn't specify which you were using.

public partial class Default7 : System.Web.UI.Page
{

    protected void RespondButton_Click(object sender, EventArgs e)
    {
        Page.ClientScript.RegisterStartupScript(this.GetType(), "someScript", "showTable();", true);
    }
} 

Open in new window

Used Modal Popup Extender