如何在pageload上使用jquery弹出div [英] how to popup a div using jquery on pageload
问题描述
我有一个条件,我想在页面加载时显示弹出div,具体取决于查询字符串。如果查询字符串值不为null或为空,那么我想显示弹出消息,否则关闭弹出窗口。
我的代码
< head> ;
< link rel =stylesheethref =http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css
type =text / cssmedia =all/>
< script src =http://ajax.googleapis.com/ajax/libs /jquery/1.4.2/jquery.min.jstype =text / javascript>< / script>
< script src =http://ajax.googleapis.com /ajax/libs/jqueryui/1.8.5/jquery-ui.min.js
type =text / javascript>< / script>
< ; script type =text / javascript>
$(function(){
< br $> b $ b
var hiddenControlValue = document.getElementById(''<%= myHiddenField.ClientID%> '')。value;
if(hiddenControlValue ==true ){
$(''#dialog'')。dialog({
modal:''true'',
title: ''title''
});
}
} );
< / Head>
< body>
< form>
I have a condition in which i want to show the pop up div on page load, depending on querystring. like if query string value not null or empty then i want to show popup message else close the popup.
my Code
<head>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/base/jquery-ui.css"
type="text/css" media="all" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
var hiddenControlValue = document.getElementById(''<%= myHiddenField.ClientID %>'').value;
if (hiddenControlValue=="true") {
$(''#dialog'').dialog({
modal: ''true'',
title: ''title''
});
}
});
</Head>
<body>
<form>
<asp:HiddenField ID="myHiddenField" runat="server" />
<div id="dialog" title="Basic dialog" style="display:none;">
<%--<p>
This is the default dialog which is useful for displaying information. The dialog
window can be moved, resized and closed with the 'x' icon.</p>--%>
<p class="txtaligncenter"> <asp:Label ID="lblLoginMsg" CssClass="failureNotification" runat="server"></asp:Label>
<asp:Button ID="btnOk" runat="server" OnClick="btnOk_Click" Text="Ok" ClientIDMode="Static"
</div>
< form>
< / body>
我的c#代码是
protected void Page_Load(object sender,EventArgs e)
{
if(!Page.IsPostBack)
{
string isonline = Request.QueryString [Isonline];
if(isonline! = null)
{
lblLoginMsg.Text =我在这里留言;
myHiddenField.Value =true;
}
}
这段代码真的很有用但问题是弹出式div中有一个按钮btnOk,我想在服务器端点击一下这个按钮,但我的事件没有开火
有人帮忙我
提前感谢
<form>
</body>
my c# code is
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string isonline = Request.QueryString["Isonline"];
if (isonline != null)
{
lblLoginMsg.Text ="My message here";
myHiddenField.Value = "true";
}
}
this code work realy but problem is that there isa button btnOk in popup div, i want to some work on server side onclick this button but my event not fire
someone help me
thanks in advance
推荐答案
(function(){
var hiddenControlValue = document.getElementById(''<%= myHiddenField.ClientID%> ;'')。值;
if(hiddenControlValue ==true){
(function () {
var hiddenControlValue = document.getElementById(''<%= myHiddenField.ClientID %>'').value;
if (hiddenControlValue=="true") {
(''#dialog'')。dialog({
modal:''true'',
title:''title''
});
}
});
< / Head>
< body>
< form>
(''#dialog'').dialog({
modal: ''true'',
title: ''title''
});
}
});
</Head>
<body>
<form>
<asp:HiddenField ID="myHiddenField" runat="server" />
<div id="dialog" title="Basic dialog" style="display:none;">
<%--<p>
This is the default dialog which is useful for displaying information. The dialog
window can be moved, resized and closed with the 'x' icon.</p>--%>
<p class="txtaligncenter"> <asp:Label ID="lblLoginMsg" CssClass="failureNotification" runat="server"></asp:Label>
<asp:Button ID="btnOk" runat="server" OnClick="btnOk_Click" Text="Ok" ClientIDMode="Static"
</div>
< form>
< / body>
我的c#代码是
protected void Page_Load(object sender,EventArgs e)
{
if(!Page.IsPostBack)
{
string isonline = Request.QueryString [Isonline];
if(isonline! = null)
{
lblLoginMsg.Text =我在这里留言;
myHiddenField.Value =true;
}
}
这段代码真的很有用但问题是弹出式div中有一个按钮btnOk,我想在服务器端点击一下这个按钮,但我的事件没有开火
有人帮忙我
提前感谢
<form>
</body>
my c# code is
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string isonline = Request.QueryString["Isonline"];
if (isonline != null)
{
lblLoginMsg.Text ="My message here";
myHiddenField.Value = "true";
}
}
this code work realy but problem is that there isa button btnOk in popup div, i want to some work on server side onclick this button but my event not fire
someone help me
thanks in advance
// ***this goes on the global scope
// get querystring as an array split on "&"
var querystring = location.search.replace( '?', '' ).split( '&' );
// declare object
var queryObj = {};
// loop through each name-value pair and populate object
for ( var i=0; i<querystring.length; i++ ) {
// get name and value
var name = querystring[i].split('=')[0];
var value = querystring[i].split('=')[1];
// populate object
queryObj[name] = value;
}
// ***now you can use queryObj["<name>"] to get the value of a url
// ***variable
if ( queryObj[ "delete" ] === "1" ) {
tab_crevents.show()
}
这篇关于如何在pageload上使用jquery弹出div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!