Avatar of vcharles
vcharles
 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
ASP.NET

Avatar of undefined
Last Comment
vcharles

8/22/2022 - Mon
Jerry Miller

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())
vcharles

ASKER
Thanks, will try it and get back to you.
vcharles

ASKER
It works Thanks! I also need to execute a command when tthe user clicks ok, can that also be done using your approach?

Victor
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Jerry Miller

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.
vcharles

ASKER
Thanks for the link, can it also be done within the Prerender method, using jsText?
vcharles

ASKER
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>
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Jerry Miller

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
vcharles

ASKER
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?
vcharles

ASKER
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.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Jerry Miller

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
vcharles

ASKER
Thank You!