Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Oct 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help in OK/CANCEL msgbox for asp.net web application

    Can anybody show me the full vb.net code on how to capture the response of a OK/CANCEL msgbox? The msgbox is done using javascript. example

    if msgbox.response then
    ....
    else
    ....
    end if

    Someone pls help me..thx alot...

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Taken from MSDN Librarys

    Displays a message in a dialog box, waits for the user to click a button, and then returns an integer indicating which button the user clicked.

    Public Function MsgBox( _
    ByVal Prompt As Object, _
    Optional ByVal Buttons As MsgBoxStyle = MsgBoxStyle.OKOnly, _
    Optional ByVal Title As Object = Nothing _
    ) As MsgBoxResult
    Parameters
    Prompt
    Required. String expression displayed as the message in the dialog box. The maximum length of Prompt is approximately 1024 characters, depending on the width of the characters used. If Prompt consists of more than one line, you can separate the lines using a carriage return character (Chr(13)), a linefeed character (Chr(10)), or a carriage return/linefeed character combination (Chr(13) & Chr(10)) between each line.
    Buttons
    Optional. Numeric expression that is the sum of values specifying the number and type of buttons to display, the icon style to use, the identity of the default button, and the modality of the message box. If you omit Buttons, the default value is zero.
    Title
    Optional. String expression displayed in the title bar of the dialog box. If you omit Title, the application name is placed in the title bar.
    Settings
    The MsgBoxStyle enumeration values are listed in the following table.

    Enumeration Value Description
    OKOnly 0 Displays OK button only.
    OKCancel 1 Displays OK and Cancel buttons.
    AbortRetryIgnore 2 Displays Abort, Retry, and Ignore buttons.
    YesNoCancel 3 Displays Yes, No, and Cancel buttons.
    YesNo 4 Displays Yes and No buttons.
    RetryCancel 5 Displays Retry and Cancel buttons.
    Critical 16 Displays Critical Message icon.
    Question 32 Displays Warning Query icon.
    Exclamation 48 Displays Warning Message icon.
    Information 64 Displays Information Message icon.
    DefaultButton1 0 First button is default.
    DefaultButton2 256 Second button is default.
    DefaultButton3 512 Third button is default.
    ApplicationModal 0 Application is modal. The user must respond to the message box before continuing work in the current application.
    SystemModal 4096 System is modal. All applications are suspended until the user responds to the message box.
    MsgBoxSetForeground 65536 Specifies the message box window as the foreground window.
    MsgBoxRight 524288 Text is right-aligned.
    MsgBoxRtlReading 1048576 Specifies text should appear as right-to-left reading on Hebrew and Arabic systems.

    The first group of values (05) describes the number and type of buttons displayed in the dialog box; the second group (16, 32, 48, 64) describes the icon style; the third group (0, 256, 512) determines which button is the default; the fourth group (0, 4096) determines the modality of the message box, and the fifth group specifies whether or not the message box window is the foreground window, along with the alignment and direction of the text. When adding numbers to create a final value for the Buttons argument, use only one number from each group.

    Return Values
    Constant Value
    OK 1
    Cancel 2
    Abort 3
    Retry 4
    Ignore 5
    Yes 6
    No 7

    Exceptions/Errors
    Exception type Error number Condition
    ArgumentException 5 Prompt is not a String expression, or Title is invalid.
    InvalidOperationException 5 Process is not running in User Interactive mode.
    InvalidEnumArgumentException 5 One or more parameters not a member of MsgBoxResult or MsgBoxStyle enumerations.

    Remarks
    If the dialog box displays a Cancel button, pressing the ESC key has the same effect as clicking Cancel. If the dialog box contains a Help button, context-sensitive Help is provided for the dialog box. However, no value is returned until one of the other buttons is clicked.

    Note To specify more than the first argument, you must use the MsgBox function in an expression. If you omit any positional arguments, you must retain the corresponding comma delimiter.
    Note The MsgBox function requires UIPermission at the SafeTopLevelWindows level, which may affect its execution in partial trust situations. For more information, see Requesting Permissions and UIPermission Class.
    Example
    This example uses the MsgBox function to display a critical-error message in a dialog box with Yes and No buttons. The No button is specified as the default response. This is done by combining the MsgBox constant values into one numeric expression. In this case, adding 4 (the Yes/No button combination) and 16 (the Critical Message window) and 256 (the second button as default button) gives a total of 276. The value returned by the MsgBox function depends on the button chosen by the user: Yes returns a value of 6; No returns a value of 7.

    Dim msg As String
    Dim title As String
    Dim style As MsgBoxStyle
    Dim response As MsgBoxResult
    msg = "Do you want to continue?" ' Define message.
    style = MsgBoxStyle.DefaultButton2 Or _
    MsgBoxStyle.Critical Or MsgBoxStyle.YesNo
    title = "MsgBox Demonstration" ' Define title.
    ' Display message.
    response = MsgBox(msg, style, title)
    If response = MsgBoxResult.Yes Then ' User chose Yes.
    ' Perform some action.
    Else
    ' Perform some other action.
    End If
    Requirements
    Namespace: Microsoft.VisualBasic

    Module: Interaction

    Assembly: Microsoft.Visual Basic .NET Runtime (in MicrosoftVisualBasic.dll)

  • #3
    New Coder
    Join Date
    Jul 2002
    Posts
    45
    Thanks
    0
    Thanked 0 Times in 0 Posts

    sorry thats .net not asp.net

    may be the same.

    Sorry.

  • #4
    Regular Coder Cipher's Avatar
    Join Date
    Dec 2004
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    to do that you must use JavaScript, can you tell me where do you want to do that?! i mean in DataGrid Button or normal button!!
    i need a creative atmosphere

  • #5
    Regular Coder Cipher's Avatar
    Join Date
    Dec 2004
    Posts
    123
    Thanks
    0
    Thanked 0 Times in 0 Posts
    well it wont different much actualy , here's how to do it
    first you need a JS function and you can place it anywhere, Body or Head

    function confirmDelete() {
    return window.confirm("are you sure?");
    }


    in Page_Load function:

    Button1.Attributes.Add("OnClick", "return confirmDelete()")

    if its in DataGrid Item Template

    Dim i As Integer
    For i = 0 To DataGrid1.Items.Count - 1
    Dim Btn as Button = DataGrid1.Item(i).FindControl("Button1")
    Btn.Attributes.Add("OnClick", "return confirmDelete()")
    Next


    Hope it works
    i need a creative atmosphere

  • #6
    New to the CF scene
    Join Date
    Nov 2005
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    I need to do the same thing, accept I need to do more things in the click event in the button. The message box needs to pop up on a condition.

    thx,
    Dave


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •