2011-12-01 80 views
3

我有一个任务板,某人正在处理某个任务,如果任务由他的经理分配给另一个人,那么第一个正在任务板上工作的人,他的执行应该停止,并且应显示一条消息“此任务已分配给其他人”。停止执行页面

我试过在页面加载中使用以下内容。

//Code Behind 
if (!Owner) 
{ 
    SomecontrolsToHide(); 
    MessageDisplay(); // JavaScript function call using RegisterStartupScript() 
    Response.End();  
} 

protected void MessageDisplay() 
{ 
    string dbMessage = "Task is assigned to someone else."; 
    ClientScriptManager cs = Page.ClientScript; 
    cs.RegisterStartupScript(typeof(Page), "ShowMessageWrapup_" + UniqueID, "showMessageDisplay('','" + dbMessage + "');", true); 
} 
// JavaScript function that displays message. 
function showMessageDisplay(args, displayMessage) { 
    if (displayMessage != "") {       
     document.getElementById("spanMessage").innerHTML = displayMessage; 
     document.getElementById("spanMessage").style.display = 'inline'; 
    } 
} 

它停止执行,但不显示信息和控制是不是隐藏了。

我该怎么办?

+0

请门柱内侧MessageDisplay()的代码 –

+0

停止执行意味着什么都不会被后到Response.End'()发送到浏览器'。你究竟想达到什么目的? – Oded

+0

也许'redirect'或'server.transfer'会更好吗? – Eonasdan

回答

2

不要做Response.End()。只需返回而不做任何事情。

+0

怎么样,因为我在页面上有不同的事件。例如用户点击了一个按钮,那么我如何返回而不执行按钮的点击事件。 – Kash

+0

这就是你应该把(!所有者)放在哪里。 –

+0

你的意思是 if(!Owner) { return; } – Kash

0

这将显示消息框。尝试这个。

Response.Write(@"<script language='javascript'>alert('You are not allowed for this task !!!')</script>");