Hi experts,

I used Window.showModalDialog to open comment.aspx.

I need to disable the X button(top right button of IE) in my comment.aspx as entering comments is compulsory.

I've done several days of research but to no avail.

I'm guessing that it's not possible even if I use javascript.

Any ideas how can I do that?

Hi,
u need to disable the button on comments.aspx in the page load event right.u can use button.enable=false
in the page.load event.u can use document.getelementbyid("button").disabled=true in javascript .if there is some thing more in u r task post it.

Erm, Sorry what is the id for that button ?
I mean the top right corner "X" button.

I am afraid it can't be done. I was looking for the same thing a couple of months back and apparently its not allowed for some nonsensical reason. If you want a good looking message or confirm box, you might wanna try doing it with JavaScript in the form of a div within a div. The outer div occupies the full screen and blanks it out (lightbox) and the inner div's the message. The only downside is its not a modal dialog. You can achieve that by passing a function reference and associated parameters in the showMessage JS function, and call them when the user clicks the OK button etc.

var g_oncomplete = false;
var g_eventArgs = false;

// onCompleteFunc: Function/Script in string format that will be executed using eval
function showMessage(message, onCompleteFunc)
{
    // Dump the onCompleteFunc and eventArgs into global vars
    g_oncomplete = onCompleteFunc;
    
    // Display the message (check out Lightbox for ideas)
}

// This is tied to the message's OK button.
function ok_onclick()
{
   if (onCompleteFunc && onCompleteFunc != "")
      eval(onCompleteFunc);
}

This works well enough. I have got it running on a production environment and it hasn't given me any trouble. Hope it helps.

Cheers
- Vivek

Erm, Sorry what is the id for that button ?
I mean the top right corner "X" button.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.