Kash
Kash

Reputation: 245

Stop execution of a page

I have a task board, some person is working on some task, if task is assigned to another person by his manager the first person who is working on the task board, his execution should be stopped, and a message should be displayed that "This task is assigned to some one else."

I tried using following in page load.

//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';
    }
}

It stops the execution but message is not displayed and Controls are not hidden too.

What should I do?

Upvotes: 3

Views: 13878

Answers (2)

This will show the message box. Try this.

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

Upvotes: 0

Piotr Perak
Piotr Perak

Reputation: 11088

Don't do Response.End(). Just return without doing anything.

Upvotes: 4

Related Questions