确认框澄清 [英] Confirmation Box Clarification

查看:73
本文介绍了确认框澄清的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要一点澄清.
当我使用以下代码进行确认时.
我收到确认框,但是那时候只有确认框可见.
网页的其他详细信息正在变白看不见.
您能帮忙吗

Hi
I need a small clarification.
When i use the below code for confirmation.
I am getting the confirmation box but that time only the confirmation box is visile.
Web page other details are becoming white can not see.
Could you please help

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "script", "alert(''New Customer created Successfully'');", true);



谢谢



Thanks

推荐答案

请澄清您的问题.我想您想问为什么显示框时整个页面变白?如果是这样,答案是因为您是在页面加载时或在页面其余任何部分加载之前弹出警报.可以将浏览器视为浏览HTML的每一行,您逐行传递它,并执行该行所必需的任何操作,然后继续前进.因此,您的alert语句是HTML的第一行,因此该框首先显示.然后,浏览器必须等到用户单击确定"后才能继续进行处理,因为这是警报框的功能.因此,虽然显示了该框,但由于它不知道要显示什么,因此必须向用户显示一个空白页面(白页)(因为它尚未处理完页面的其余部分).

解决方案是:要么使用jQuery及其
Please clarify your question. I think your asking why the whole page goes white when the box is shown? If so, the answer is because you are making the alert pop-up as the page is loading, or rather before any of the rest of the page has been loaded. Think of the browser as working through each line of HTML you pass it line-by-line and doing whatever is necessary for that line then moving on. Your alert statement therefore comes as one of the first lines of HTML, so the box is shown first. The browser then has to wait until the user clicks okay before it can continue to process the because that is the function of the alert box. So while the box is shown it has to display a blank (white) page to the user as it does not know what else to show (since it hasn''t processed the rest of your page).

The solution is to either: Use jQuery and it''s


(document).ready方法,使警报框仅在页面的其余部分已经处理和呈现后才出现,或者使用C#Literal控件在末尾添加脚本块您的输出.例如

(document).ready method to make your alert box appear only when the rest of the page has been processed and rendered or to use the C# Literal control to add your script block at the end of your output. E.g.

void Page_Load(/*whatever args go here*/)
{
   //Add in all your other output here (basically put all your other code here)
   
   //Now add in the alert box
   Literal ScriptSection = new Literal();
   ScriptSection.Text = "<script lang=\"text/javascript\">alert('Hello world!');</script>";
   Page.Form.Controls.Add(ScriptSection);
   //For the above line you could also use any control on your page e.g. MyControl.Controls.Add 
}



Literal控件会输出与您设置的文本完全相同的文本-它绕过ASP.Net处理,基本上意味着您可以在代码中编写HTML.但是请注意,如果使用过多,这会使代码变得混乱!

希望这会有所帮助,
埃德


有用的链接:

jQuery.ready: http://api.jquery.com/ready/ [ http://msdn.microsoft.com/zh-我们/library/system.web.ui.webcontrols.literal.aspx [



The Literal control outputs exactly whatever text you set it to - it bypasses ASP.Net processing basically meaning you can write HTML in your code. Be warned though, this makes code messy if used too much!

Hope this helps,
Ed


Useful links:

jQuery.ready : http://api.jquery.com/ready/[^]

MSDN Literal control : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.literal.aspx[^]


Arokia,我已经发布了您的答案,如果它可以解决您的问题,请评分这个.
Hi, Arokia, i have posted your answer already, if it solves your problem then rate this.


这篇关于确认框澄清的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆