admin管理员组文章数量:1420606
im very new to C# and ASP.Net. Does anybody know how to create a popup in Asp?
My scenario:
When I click on a button, it checks some states. If a condition is being fulfilled a popup shall be thrown due to the state (here: achieved percentages).
So 2 invidual Popup Windows shall be thrown by clicking the same button.
(Do you want to abort the contract, which wasn't pleted? Yes - No)
(Do you want to pleted the contract, which hasn't achieved the target? Yes - No)
So the dialog boxes shall appear according for the same button when the condition was fullfilled.
Can anybody help me? (Code behind in C# and javascript?)
im very new to C# and ASP.Net. Does anybody know how to create a popup in Asp?
My scenario:
When I click on a button, it checks some states. If a condition is being fulfilled a popup shall be thrown due to the state (here: achieved percentages).
So 2 invidual Popup Windows shall be thrown by clicking the same button.
(Do you want to abort the contract, which wasn't pleted? Yes - No)
(Do you want to pleted the contract, which hasn't achieved the target? Yes - No)
So the dialog boxes shall appear according for the same button when the condition was fullfilled.
Can anybody help me? (Code behind in C# and javascript?)
Share Improve this question edited Jun 20, 2020 at 9:12 CommunityBot 11 silver badge asked Aug 29, 2013 at 14:55 MoonstarMoonstar 2471 gold badge5 silver badges13 bronze badges2 Answers
Reset to default 0We used this to call a js function which built/shows a popup. Hope it is of some help.
protected void ibtnEdit_Click(object sender, ImageClickEventArgs e)
{
// do some stuff then call a js function to show a popup
Page.ClientScript.RegisterStartupScript(this.GetType(), "clientScript", "<script language=JavaScript>showAPopUp();</script>");
}
Edit: In the aspx define the js function for example:
<script>
function showAPopUp()
{
$( "#MyDialog" ).dialog( "open" );
//alert("some simple message");
}
</script>
Which would work with code like shown here with jquery ui (http://jqueryui./dialog/). Or use alert for a simple popup as per the mented out line.
Edit 2:
if (confirm("Confirm something?") == true)
{
// they pressed ok
}
else
{
// they cancelled
}
Thanks everybody who tried to help.
I decided to use Javascript.
Here is a code excerpt of the aspx-File:
<pre lang="cs"><script type="text/javascript" language="javascript">
String.Format = function () {
var s = arguments[0];
for (var i = 0; i < arguments.length - 1; i++) {
var reg = new RegExp("\\{" + i + "\\}", "gm");
s = s.replace(reg, arguments[i + 1]);
}
return s;
};
var dialogConfirmed = false;
function SetDialogConfirmedFalse() {
dialogConfirmed = false;
}
function ConfirmDialog(obj, title, dialogText) {
if (!dialogConfirmed) { //!$('#dialog').is(':data(dialog)')
$('body').append(String.Format("<div id='dialog' title='{0}'><p>{1}</p></div>",
title, dialogText));
$('#dialog').dialog({
height: 110,
modal: true,
resizable: false,
draggable: false,
close: function (event, ui) { $('body').find('#dialog').remove(); },
buttons:
{
'Ja': function () {
$('#dialog').dialog('close');
dialogConfirmed = true;
if (obj) obj.click();
},
'Nein': function () {
$('#dialog').dialog('close');
}
}
});
$(".ui-widget").css({ "font-size": +18 + "px" });
}
return dialogConfirmed;
}</pre>
Code behind the in CS-File int he Eventhandler which throws this popup:
<pre lang="cs">var script = "ConfirmDialog(this, '" + CommonRes.Attention +
"Wollen Sie wirklich beenden?");";
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), script, true);</pre>
本文标签: cPopup Window in ASPNetStack Overflow
版权声明:本文标题:c# - Popup Window in ASP.Net - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745336345a2654058.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论