Click here to Skip to main content
15,883,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have javascript and css style applied for a page.

My problem is when i click the add new button, it does not postback coz it is in update panel.

But javascript and css style applied for the control is not working.

ASP.NET
//=================

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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 id="Head1" runat="server">
    <title>Untitled Page</title>
    <style type="text/css">
        .round1
        {
            -moz-border-radius: 10px;
            -webkit-border-radius: 10px;
            background: #FFF;
            border: 1px solid #FF8855;
            border-radius: 30px;
            font: small Verdana;
            height: auto;
            padding: 5px;
            width: 300px;
        }
    </style>

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
 <script src="autohide.js" type="text/javascript"></script>


</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

    <div style="height: 261px">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>



                <asp:Panel ID="Panel_MSG" runat="server" Visible="False">
        <div id="alert" class="round1">
            <asp:Label ID="lbl_msg" runat="server" Visible="False"></asp:Label>
        </div>
</asp:Panel>
                <div style="text-align: center">
                    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" /></div>
            </ContentTemplate>
        </asp:UpdatePanel>

        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <div style="text-align: center">
                    <asp:Button ID="Button2" runat="server" Text="Button" onclick="Button2_Click" /></div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

//========== code

C#
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    public void dislyMSG(string MSGTXT)
    {
        Panel_MSG.Visible = true;
        lbl_msg.Visible = true;
        lbl_msg.Text = MSGTXT.ToString();
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        dislyMSG("Hello................2");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        dislyMSG("Hello................1");
    }
}


[edit]code blocks fixed[/edit]
Posted
Updated 25-Nov-12 10:45am
v2

1 solution

C#
<asp:updatepanel id="UpdatePanel1" runat="server" EnableViewState="true"></asp:updatepanel>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900