detect if modal is currently active - c#

how can i detect if a modalpopupextender is currently being shown using javascript?
Modalpopupextender markup
<!-- Add Files Modal Form -->
<asp:HiddenField ID="AddFilesForModal" runat="server" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="AddFilesModal" BehaviorID="modalPopupExtenderAddFiles"
TargetControlID="dummyButtonAddToPendingList" PopupDragHandleControlID="PanelAddFilesOuter" PopupControlID="PanelAddFilesOuter"
OkControlID="dummyButtonAddToPendingList" BackgroundCssClass="modalBackground" DropShadow="false"
Drag="true">
</ajaxToolkit:ModalPopupExtender>
<ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender4" runat="server" TargetControlID="PanelAddFilesInner">
</ajaxToolkit:RoundedCornersExtender>
<asp:Panel ID="PanelAddFilesOuter" runat="server" BackColor="Transparent" Style="display: none;">
<asp:Panel ID="PanelAddFilesInner" runat="server" BackColor="White" Style=" width:800px; height:600px; overflow:auto;">
<ContentTemplate>
<div id="AddFilesContainer" style=" padding-left:10px; padding-right:10px; padding-top:10px; padding-bottom:5px;">
<br />
Add Files
<div id="AddFiles_Div" style="height:80%;overflow:auto;">
<asp:TreeView ID="TreeViewAddItems" runat="server" Height="500px" ShowCheckBoxes="Leaf"
Width="380px" ImageSet="XPFileExplorer" NodeIndent="15" PathSeparator="\" ShowExpandCollapse="true"
EnableClientScript="true" OnTreeNodeCheckChanged="OnTreeNodeCheckChanged" OnAdaptedTreeNodeCheckChanged="OnTreeNodeCheckChanged" ShowLines="True">
<HoverNodeStyle Font-Underline="True" ForeColor="#6666AA" />
<NodeStyle Font-Names="Tahoma" Font-Size="10pt" ForeColor="Black" HorizontalPadding="2px"
NodeSpacing="0px" VerticalPadding="2px" />
<ParentNodeStyle Font-Bold="False" />
<SelectedNodeStyle BackColor="#B5B5B5" Font-Underline="False" HorizontalPadding="0px"
VerticalPadding="0px" />
</asp:TreeView>
</div>
<br />
<div class="base" style="height:20px;">
<asp:LinkButton ID="lnkAddToPendingList" runat="server" OnClick="BtnAddToPendingList_Click" BorderStyle="Solid" BackColor="#CCCCCC">Add selected items to list</asp:LinkButton>
<asp:Button CssClass="Button" ID="dummyButtonAddToPendingList" runat="server" Style="display: none;" />
<asp:Button CssClass="Button" ID="CancelAddFiles" runat="server" Text="Cancel" OnClientClick="$find('modalPopupExtenderAddFiles').hide(); return false;" />
</div>
</div>
</ContentTemplate>
</asp:Panel>
</asp:Panel>
<!-- End Add Files Modal Form -->

I don't think there is a property you can call. You probably need to hook into the shown and hiding events. Something like this:
var amIVisible = false;
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(function () {
$find('modalPopupExtenderAddFiles').add_shown(function () {
amIVisible = true;
});
$find('modalPopupExtenderAddFiles').add_hidden(function () {
amIVisible = false;
});
});

Use the BehaviourID to verify it on the client side:
<script type="text/javascript">
function IsVisible()
{
var modalPopup = $find('ModalBehaviourID');
return modalPopup ? true : false;
}
</script>
Second option:
<script type="text/javascript" >
function IsVisible()
{
return $find('ModalBehaviourID').get_PopupVisible();
}
</script>
Source: Link

Related

How to hide and view ModalPopupExtender?

I am using 4 Modalpopupextender in my start-up page of my project. When I run my start-up page, the panels which I have set under PopupControlID in Modalpopupextender are visible even before the specified TargetControlID is clicked. I have tried to set visible of those to false but it dint helped me and I also tried to create a css class to hide a panel when page is loaded and to view the panel when specified button is clicked but it neither helped me. Please help. Thank you.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<style type = "text/css">
.hidePanel
{
display:none;
}
.showpanel
{
display : block;
}
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:modalpopupextender ID="Modalpopupextender1" CancelControlID = "Button8" TargetControlID = "Button2" PopupControlID = "StaffSP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender2" CancelControlID = "Button10" TargetControlID = "Button3" PopupControlID = "StaffFP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender3" CancelControlID = "Button12" TargetControlID = "Button5" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:modalpopupextender ID="Modalpopupextender4" CancelControlID = "Button14" TargetControlID = "Button6" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "Main" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-removed 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-removed 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-removed 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
</div>
<asp:Panel ID="StaffLogin" runat="server" Height="59px"
style="z-index: 1; left: 302px; top: 112px; position: absolute; height: 59px; width: 275px"
Visible="False" Width="275px">
Staff<br />
<asp:Button ID="Button1" runat="server" Text="Login" />
<asp:Button ID="Button2" runat="server" Text="New Staff" />
<asp:Button ID="Button3" runat="server" Text="Fogot Password" />
</asp:Panel>
<asp:Panel ID="AdminLogin" runat="server"
style="z-index: 1; left: 302px; top: 193px; position: absolute; height: 78px; width: 275px"
Visible="False" Width="275px">
Admin<br />
<asp:Button ID="Button4" runat="server" Text="Login" />
<asp:Button ID="Button5" runat="server" Text="New Admin" />
<asp:Button ID="Button6" runat="server" Text="Forgot Password" />
</asp:Panel>
<asp:Panel ID="StaffSP" runat="server" Height="48px" Width="274px">
Staff SP<br />
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" runat="server" Height="48px" Width="274px">
Staff FP<br />
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" runat="server" Height="48px" Width="274px">
Admin SP<br />
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" runat="server" Height="48px" Width="274px">
AdminFP<br />
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TrailPopup : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void LinkAdmin_Click(object sender, EventArgs e)
{
AdminLogin.Visible = true;
StaffLogin.Visible = false;
}
protected void LinkStaff_Click(object sender, EventArgs e)
{
AdminLogin.Visible = false;
StaffLogin.Visible = true;
}
}
EDIT :
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<style type = "text/css">
.hidePanel
{
display:none;
}
.showpanel
{
display : block;
}
.panel
{
background : gray;
padding : 10px;
}
div ul ul
{
display: none;
}
div ul li:hover > ul
{
display: block;
}
div ul li ul:hover > ul
{
display: block;
}
</style>
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="XX-Large" Text="Automated Examination System"></asp:Label><br /> <br /><br />
<asp:Panel ID = "Main" runat = "server" Height="181px" Width="275px">
<ul>
<li style="margin-left: 33px; width: 169px;"> <asp:LinkButton ID = "LinkAdmin" runat = "server" onclick="LinkAdmin_Click">Coordinator</asp:LinkButton></li>
<li style="width: 172px; margin-left: 33px"> <asp:LinkButton ID="LinkStaff" runat="server" onclick="LinkStaff_Click">Staff</asp:LinkButton></li>
<li style="margin-left: 33px"> <asp:LinkButton ID = "LinkStudent" runat = "server">Student</asp:LinkButton>
<ul>
<li><asp:LinkButton ID = "LinkButton1" runat = "server">Fresh Registration</asp:LinkButton></li>
<li><asp:LinkButton ID = "LinkButton2" runat = "server">Re Registration</asp:LinkButton></li>
</ul>
</li>
</ul>
</asp:Panel>
</div>
<asp:Panel ID="StaffLogin" runat="server" Height="59px"
style="z-index: 1; left: 302px; top: 112px; position: absolute; height: 59px; width: 275px"
Visible="False" Width="275px">
Staff<br />
<asp:Button ID="Button1" runat="server" Text="Login" />
<asp:Button ID="Button2" runat="server" Text="New Staff" />
<asp:Button ID="Button3" runat="server" Text="Fogot Password" />
</asp:Panel>
<asp:Panel ID="AdminLogin" runat="server" style="left: 302px; top: 193px; position: absolute; height: 78px; width: 275px" Visible="False" Width="275px">Admin<br />
<asp:Button ID="Button4" runat="server" Text="Login" />
<asp:Button ID="Button5" runat="server" Text="New Admin" />
<asp:Button ID="Button6" runat="server" Text="Forgot Password" />
</asp:Panel>
<asp:Panel ID="StaffSP" Visible = "false" runat="server" Height="48px" Width="274px">
Staff SP<br />
<asp:modalpopupextender ID="Modalpopupextender1" CancelControlID = "Button8" TargetControlID = "Button2" PopupControlID = "StaffSP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" Visible = "false" runat="server" Height="48px" Width="274px">
Staff FP<br />
<asp:modalpopupextender ID="Modalpopupextender2" CancelControlID = "Button10" TargetControlID = "Button3" PopupControlID = "StaffFP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" Visible = "false" runat="server" Height="48px" Width="274px">
Admin SP<br />
<asp:modalpopupextender ID="Modalpopupextender4" CancelControlID = "Button14" TargetControlID = "Button6" PopupControlID = "AdminSP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" Visible = "false" runat="server" Height="48px" Width="274px">
AdminFP<br />
<asp:modalpopupextender ID="Modalpopupextender3" CancelControlID = "Button12" TargetControlID = "Button5" PopupControlID = "AdminFP" runat="server"></asp:modalpopupextender>
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>
</form>
</body>
</html>
Call your css class hide panel in every PopupControl used for modalpopupextender control:
`<asp:Panel ID="StaffSP" runat="server" CssClass="hide" Height="48px" Width="274px" >
Staff SP<br />
<asp:Button ID="Button7" runat="server" Text="Button" />
<asp:Button ID="Button8" runat="server" Text="Cancel" />
</asp:Panel>
<asp:Panel ID="StaffFP" runat="server" Height="48px" Width="274px" style="display:none;">
Staff FP<br />
<asp:Button ID="Button9" runat="server" Text="Button" />
<asp:Button ID="Button10" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminSP" runat="server" Height="48px" Width="274px" CssClass="hidePanel">
Admin SP<br />
<asp:Button ID="Button11" runat="server" Text="Button" />
<asp:Button ID="Button12" runat="server" Text="Cancel" />
<br />
<br />
</asp:Panel>
<asp:Panel ID="AdminFP" runat="server" Height="48px" Width="274px" Visible="false">
AdminFP<br />
<asp:Button ID="Button13" runat="server" Text="Button" />
<asp:Button ID="Button14" runat="server" Text="Cancel" />
</asp:Panel>`
you have put all the 4 TargetControlIDs inside the panels which are not visible

Why does my asp update panel only refresh once

Hi I have an asp updatePanel which contains several asp panels. The way it should function is you click the button in the first panel it hides that panel and shows the next. That works fine the problem comes with the next panel. If I try and use either of the button controls within that panel nothing happens.
Heres the html
<asp:UpdatePanel runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align:left; width:90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px;
margin-top: 10px" Width="100px" onclick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" onclick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px;
margin-top: 10px" Width="100px" ValidationGroup="rejCom"
onclick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
c# code
protected void btnReject_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = true;
pnlAppRej.Visible = false;
}
protected void btnBackRejCom_Click(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
its the btnBackRejCom_Click method which doesnt seem to fire. But I have tested setting the pnlRejCom to visible and the method works fine.
Thanks in advance
Charlie
your problem seems to be different.
I would suggest, delete the
protected void btnBackRejCom_Click(object sender, EventArgs e){}
and again create a new event.
This is what i tried and is working fine now.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:PostBackTrigger ControlID="btnReject" />
<asp:AsyncPostBackTrigger ControlID="btnBackRejCom" />
<asp:PostBackTrigger ControlID="btnDoneRejCom" />
</Triggers>
<ContentTemplate>
<asp:Panel ID="pnlAppRej" runat="server" HorizontalAlign="Center" CssClass="textBox"
Width="85%" Visible="True">
<div style="text-align: left; width: 90%">
<asp:Label ID="lblAppRej" runat="server" Text="Label"></asp:Label>
</div>
<asp:Button ID="btnApprove" runat="server" Text="Approve" CssClass="button" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnApprove_Click" />
<asp:Button ID="btnReject" runat="server" CssClass="button" Text="Reject" Style="margin-left: 20px"
Width="100px" OnClick="btnReject_Click" />
</asp:Panel>
<asp:Panel runat="server" ID="pnlRejCom" Width="85%" Visible="False" CssClass="textBox">
<div style="text-align: left">
Comments<br />
</div>
<asp:TextBox ID="tbRejCom" runat="server" Height="54px" TextMode="MultiLine" Width="95%"
CssClass="textBox" Style="margin-top: 5px" ValidationGroup="rejCom"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbRejCom"
ErrorMessage="RequiredFieldValidator" ValidationGroup="rejCom">*</asp:RequiredFieldValidator>
<br />
<div style="text-align: center">
<asp:Button ID="btnBackRejCom" runat="server" CssClass="button" Text="Back" Style="margin-right: 20px; margin-top: 10px"
Width="100px" OnClick="btnBackRejCom_Click1" />
<asp:Button ID="btnDoneRejCom" runat="server" CssClass="button" Text="Done" Style="margin-left: 20px; margin-top: 10px"
Width="100px" ValidationGroup="rejCom"
OnClick="btnDoneRejCom_Click" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
code behind :
protected void btnBackRejCom_Click1(object sender, EventArgs e)
{
pnlRejCom.Visible = false;
pnlAppRej.Visible = true;
}
Hope this helps. Happy Coding..!!!
I have same problem so I have just added CausesValidation="False" then it works fine for me.so please add CausesValidation in btnBackRejCom button like as below
Please try it
<asp:Button ID="btnBackRejCom" runat="server" CausesValidation="False" CssClass="button" Text="Back" Style="margin-right: 20px;
margin-top: 10px" Width="100px" />
I think It works for you :)

Script manager won't work

I have a master page and their is script manager with update panel inside it. . now i am trying to add update panel in content page without using script manager but it gives me an error:
The control with ID 'updpanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.
I know i can use only one instance of script manager, then i tried ScriptManagerProxy but it gives me the error that scriptMangerProxy requires script manager.
I also tried ajax:ToolScriptManager but it also gives the same results
So the question is how can make the update panel to work in content page..
Master Page:
<%# Master Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="SideMaster.master.cs" Inherits="SideMaster" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/jscript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#chit').scrollTop(1000000);
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="sidemenu">
<asp:SiteMapDataSource ID="topNav" runat="server" />
<asp:Menu ID="SideMenu" runat="server" DataSourceID="topNav" CssClass="SideMenu" StaticDisplayLevels="4"
Font-Bold="true" Font-Size="20" IncludeStyleBlock="true" >
<StaticMenuItemStyle VerticalPadding="5" BackColor="#670a0a" ForeColor="White" HorizontalPadding="5" />
<StaticSelectedStyle BackColor="White" ForeColor="#670a0a" />
</asp:Menu>
</div>
<div class="cont3" >
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="rightmenu">
<div class="newspan">
<asp:Repeater ID="RepNews" runat="server" >
<HeaderTemplate><div class="newsheadcont">News & Events</div></HeaderTemplate>
<ItemTemplate>
<div class="newstemp">
<hr />
# <%#Eval("News") %>
<asp:LinkButton ID="LinkNews" runat="server" CssClass="welcomeMore"></asp:LinkButton>
</div>
</ItemTemplate>
</asp:Repeater>
</div>
<br /><br />
<div class="chatcont" style="margin-left:1%;">
<div class="chat">
<h2 class="chathead">Peoples Talking About </h2>
<asp:ScriptManager ID="scmang" runat="server"></asp:ScriptManager>
<%--<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</ajaxToolkit:ToolkitScriptManager>--%>
<script type="text/javascript">
var xPos, yPos;
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_beginRequest(BeginRequestHandler);
prm.add_endRequest(EndRequestHandler);
function BeginRequestHandler(sender, args) {
xPos = $get('chit').scrollLeft;
yPos = $get('chit').scrollTop;
}
function EndRequestHandler(sender, args) {
$get('chit').scrollLeft = xPos;
$get('chit').scrollTop = yPos;
}
</script>
<asp:UpdatePanel ID="updPanelChat" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional" >
<ContentTemplate>
<asp:Panel ID="pan" runat="server">
<asp:ListView ID="ListChat" runat="server" >
<LayoutTemplate>
<div class="chattemp" style="width:250px; " id="chit" >
<asp:PlaceHolder runat="server" ID="itemPlaceholder"></asp:PlaceHolder>
</div>
</LayoutTemplate>
<ItemSeparatorTemplate><hr /></ItemSeparatorTemplate>
<EmptyDataTemplate>No Data Found</EmptyDataTemplate>
<ItemTemplate>
<div class="chatbox" >
<div class="chatpic" style="margin:18px 0px 0px 0px;" >
<asp:ImageButton ID="ImageChat" runat="server"
ToolTip='<%#Eval("UserName") %>'
ImageUrl='<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'
Width="50" Height="50" />
</div>
<div class="chatbubble" style="width:160px; margin:-50px 5px 5px 60px; float:left;">
<asp:Label ID="LabelChat" runat="server" Width="100" Height="50"><%#Eval("Body") %></asp:Label>
</div>
<div class="chatname" style="width:50px; border:none;" >
<asp:LinkButton ID="LinkUserName" runat="server"
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>'><%#Eval("UserName") %></asp:LinkButton>
</div>
</div>
</ItemTemplate>
</asp:ListView>
<asp:Timer ID="TimerUpdate" runat="server" Interval="20000"
ontick="TimerUpdate_Tick"></asp:Timer>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<div class="messagebox" style="width:250px; height:120px; border:none;">
<asp:TextBox ID="TextBoxMessage" runat="server" TextMode="MultiLine" Visible="false" Width="250" Height="80" MaxLength="500"></asp:TextBox>
<asp:Button ID="ButtonMessage" runat="server" Text="Comment"
onclick="ButtonMessage_Click" Visible="false" />
</div>
</div>
</div>
</div>
</asp:Content>
Content Page:
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="interface" >
<table>
<tr>
<td align="center">
<div class="goog">
<asp:LinkButton ID="LinkFind" runat="server" CssClass="linkgoog">Find</asp:LinkButton>
</div>
</td></tr>
<tr><td align="left">
<div>
<asp:TextBox ID="TextBoxSearch" runat="server" Width="600" Height="40"></asp:TextBox>
<asp:Button ID="ButtonSearch" runat="server" Text="SEARCH" CssClass="loginbt"
onclick="ButtonSearch_Click1" /><br />
</div>
</td></tr>
</table>
</div>
<br />
<div class="interface">
<asp:UpdatePanel ID="updpanel" runat="server">
<ContentTemplate>
<asp:GridView ID="GridAll" runat="server"
onitemcommand="GridAll_ItemCommand" AutoGenerateColumns="false" CellPadding="10" AllowPaging="true" PageSize="3" OnPageIndexChanging="GridAll_PageIndexChanging" >
<Columns>
<asp:TemplateField HeaderText="Name" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:LinkButton ID="lnkname" runat="server"
Text='<%#Eval("Name") %>'
PostBackUrl='<%#"~/Profile/Profile.aspx?Name="+Eval("UserName") %>' CssClass="welcomeMore"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Department" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20" >
<ItemTemplate>
<span class="googtext"><%#Eval("Department") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<span class="googtext"><%#Eval("Year") %></span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Photo" HeaderStyle-BackColor="#670a0a" HeaderStyle-ForeColor="White" HeaderStyle-Font-Size="20">
<ItemTemplate>
<asp:Image ID="ImageProfile" runat="server" ImageUrl = '<%# "~/ShowImage.ashx?Name=" + Server.UrlEncode(Eval("UserName").ToString()) %>' Width="150" Height="150" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
<div class="emptytext">No Match Found</div>
</EmptyDataTemplate>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Content>
Your help will be appreciated. . . Thank you
You should have only one script manager in master page above update panel.
In any of the content page you can use update panel as there is already script manager in master page. Also you should provide some code for your problem.

CheckBox All only works first two times

I put a checkbox 'Check All', and my code only works first all check and all uncheked. After that none of the checked box follows the attribute of the checkbox of 'Check All'
<script type="text/javascript">
$(function () {
$('#chkAll').click(function () {
$('#divChk .chk input:checkbox').attr('checked', function () {
return $('#chkAll').prop('checked');
});
});
});
</script>
<body>
<form id="form1" runat="server">
<div class="bigDiv">
<asp:CheckBox ID="chkAll" runat="server" Text="Check All" /><br />
<div id="divChk">
<asp:CheckBox ID="CheckBox1" runat="server" Text="1" CssClass="chk" /><br />
<asp:CheckBox ID="CheckBox2" runat="server" Text="2" CssClass="chk" /><br />
<asp:CheckBox ID="CheckBox3" runat="server" Text="3" CssClass="chk" /><br />
<asp:CheckBox ID="CheckBox4" runat="server" Text="4" CssClass="chk" /><br />
</div>
</div>
</form>
</body>
Try this and see if this works.
$('#chkAll').change(function () {
$('#divChk input:checkbox').prop('checked',this.checked);
});

Stop ModalPopup Extender to popup

I have a modal popup extender which fires on a button click ... now irrespective on the onclientclick function return value true/false its always poping up. I need to stop the modal to fire on return of false and modal to fire the return to true..how to do this?
Please find the code below :
<div style="text-align:center;" runat="server" id="pnlButton">
<asp:Button CssClass="button" ID="btnBack" runat="server" Text="Back"
Width="120px" onclick="btnBack_Click" UseSubmitBehavior="false" />
<asp:Button CssClass="button" ID="btnCancel" runat="server"
Text="Cancel Request" Width="130px" onclick="btnCancel_Click" onClientClick="Validate();" />
</div>
<div style="text-align:center;">
<asp:Button CssClass="button" ID="btnDone" Visible="false" runat="server"
Text="Done" Width="110px" onclick="btnDone_Click" />
</div>
<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server"
TargetControlID="btnCancel"
DisplayModalPopupID="ModalPopupExtender1"
ConfirmText="Are you sure you want to click this?" />
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCancel"
PopupControlID="PNL" OkControlID="ButtonOk" CancelControlID="ButtonCancel" BackgroundCssClass="modalBackground" />
<asp:Panel ID="PNL" runat="server" Style="display: none; width: 400px; background-color: White;
border-width: 2px; border-color: Black; border-style: solid; padding: 20px;">
<h2>Are you sure you want to cancel this request?</h2>
<br />
<br />
<div style="text-align: right;">
<asp:Button ID="ButtonOk" runat="server" Text="Yes" CssClass="button" />
<asp:Button ID="ButtonCancel" runat="server" Text="No" CssClass="button" />
</div>
</asp:Panel>
You can open Popup from javascript
function ValidateAndOpen(){
if(Validate()){
var modalDialog = $find("ModalPopupExtender1");
// get reference to modal popup using the AJAX api $find() function
if (modalDialog != null) {
modalDialog.show();
}
}
return false;
}
You must set ClientIDMode="Static" on ModalPopupExtender
and set OnClientClick="return ValidateAndOpen();"
change you code to the following
onClientClick="return Validate();"
Put this script onto your form:
function pageLoad(sender, args) {
if (args.get_isPartialLoad() === false) {
$find("<%= ModalPopupExtender1.ClientID %>").add_showing(function (sender, args) { args.set_cancel(Validate()); });
}
}

Categories

Resources