Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with replacing Wndows Message Box

Hello

I am trying to provide users instructions in my application, what is the simplest approach to replace a Windows' Message Box?

Victor
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

I have used this in the PreRender event of the button. It adds the attribute to the button to be displayed on button click.

 Dim jsText As New StringBuilder()
            jsText.Append("return confirm('Delete this contact ID? Click OK to continue or Cancel to return');")
            btnSubmitContacts.Attributes.Add("language", "javascript")
            btnSubmitContacts.Attributes.Add("OnClick", jsText.ToString())
Avatar of Victor  Charles

ASKER

Thanks, will try it and get back to you.
It works Thanks! I also need to execute a command when tthe user clicks ok, can that also be done using your approach?

Victor
Clicking OK in the confirm box returns true, cancel returns false. You should be able to check that value and perform code based on that value in the Click event for the button that contains the pop-up message.

http://www.javascripter.net/faq/confirm.htm.
Thanks for the link, can it also be done within the Prerender method, using jsText?
I tried the code from the link but got the following error:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: BC30456: 'if' is not a member of 'ASP.update_aspx'.

Source Error:

 

Line 838:                  
Line 839:                    <td class="style1246" bgcolor="Silver" valign="top">
Line 840:                        <asp:Button ID="Button3" runat="server" Text="?" Width="26px" onClick="if(confirm('Format the hard disk?')) alert('You are very brave!');
Line 841:                         else alert('A wise decision!')"/>
Line 842:                    </td>
If you put the code that you want run in the Click event of the button, it should only run when the user clicks OK on the button. I put the following code in a test button on my site and it only changes the text when OK is clicked. Click on Cancel does nothing.

Protected Sub btnSubmit_Prerender(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.PreRender

        Dim jsText As New StringBuilder()
        jsText.Append("return confirm('Delete this contact ID? Click OK to continue or Cancel to return');")
        btnSubmit.Attributes.Add("language", "javascript")
        btnSubmit.Attributes.Add("OnClick", jsText.ToString())
    End Sub

    Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        Me.btnSubmit.Text = "Test Click"

    End Sub
It also works on my side. Thanks.  If  I want to just display a message and have an ok button, how do I remove the cancel bitton? or how do I just have a Close button?
Hi again.

Is it possible to change header Windows Explorer to another text?  Also as mentioned I need to use a message to just display data about a field, in this case I would just need an OK or close button. The second purpose is to infor users wheter they want to save an entry, in this case I would need an OK/Cancel or Yes/NO buttons.

If a user enters the wrong data how do I use the message both to inform them to enter the data in the right format? Not certain it can be done, since at that point I don't believe I can provide a message in Prerender mode.
ASKER CERTIFIED SOLUTION
Avatar of Jerry Miller
Jerry Miller
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank You!