A way to use MessageBox.Show in C# method

Hi experts, I need to use MessageBox in C# method as below: MessageBoxResult result = MessageBox.Show(messageBoxText, caption, button, icon); But, I get an error message. "The name 'MessageBox' does not exist in the current context." Would you help me know how to do it? Thank you.
  • Hello Joseph, Please remember that methods of written using  C# and VB.NET are server side methods. The code is running on the server and not on user computer, as so you can't trigger dialog on the user computer when it executed on the server.  The concept of Server-Client development is different than Winforms (or client only). As I'm not familiar with your task, I can only guess that you want to achieve one of the following:
    1. Show Error\Info message box with OK button
    2. Interact with the user - ask a question and then process based on his response
    <h4>Show Error\Info message box with OK button</h4> If you need to return error in Aras you can return from your server side code following result and this will rise dialog with your message:
    return this.getInnovator().newError("YOUR_ERROR_TEXT");
    If you need to return Info dialog that mean something like: "Done - you can keep working", you need to return from your server side code:
    return this.getInnovator().newResult("YOUR_INFO_TEXT OR EMPTY STRING")
    Notice: dependence on configuration this text will not be shown or will be shown as small popup on the left bottom corner of the screen. <h4>Interact with the user - ask a question and then process based on his response</h4> In my opinion if it's possible, try to collect as much input as possible before running the server code. If you still need to interact with the user during the execution of the server side code, it only can be done by:
    • ending your server side code - return some result that will mean for client side code that need to raise a question and return result to the server
    • saving the state in some type of structure (or by returning the result to the user)
    • ask for input
    • then run new server side code that contains user input (+ data saved from previous server execution)
  • Hello Joseph, Please remember that methods of written using  C# and VB.NET are server side methods. The code is running on the server and not on user computer, as so you can't trigger dialog on the user computer when it executed on the server.  The concept of Server-Client development is different than Winforms (or client only). As I'm not familiar with your task, I can only guess that you want to achieve one of the following:
    1. Show Error\Info message box with OK button
    2. Interact with the user - ask a question and then process based on his response
    <h4>Show Error\Info message box with OK button</h4> If you need to return error in Aras you can return from your server side code following result and this will rise dialog with your message:
    return this.getInnovator().newError("YOUR_ERROR_TEXT");
    If you need to return Info dialog that mean something like: "Done - you can keep working", you need to return from your server side code:
    return this.getInnovator().newResult("YOUR_INFO_TEXT OR EMPTY STRING")
    Notice: dependence on configuration this text will not be shown or will be shown as small popup on the left bottom corner of the screen. <h4>Interact with the user - ask a question and then process based on his response</h4> In my opinion if it's possible, try to collect as much input as possible before running the server code. If you still need to interact with the user during the execution of the server side code, it only can be done by:
    • ending your server side code - return some result that will mean for client side code that need to raise a question and return result to the server
    • saving the state in some type of structure (or by returning the result to the user)
    • ask for input
    • then run new server side code that contains user input (+ data saved from previous server execution)
  • Hello Joseph, Please remember that methods of written using  C# and VB.NET are server side methods. The code is running on the server and not on user computer, as so you can't trigger dialog on the user computer when it executed on the server.  The concept of Server-Client development is different than Winforms (or client only). As I'm not familiar with your task, I can only guess that you want to achieve one of the following:
    1. Show Error\Info message box with OK button
    2. Interact with the user - ask a question and then process based on his response
    Show Error\Info message box with OK button If you need to return error in Aras you can return from your server side code following result and this will rise dialog with your message:
    return this.getInnovator().newError("YOUR_ERROR_TEXT");
    If you need to return Info dialog that mean something like: "Done - you can keep working", you need to return from your server side code:
    return this.getInnovator().newResult("YOUR_INFO_TEXT OR EMPTY STRING")
    Notice: dependence on configuration this text will not be shown or will be shown as small popup on the left bottom corner of the screen. Interact with the user - ask a question and then process based on his response In my opinion if it's possible, try to collect as much input as possible before running the server code. If you still need to interact with the user during the execution of the server side code, it only can be done by:
    • ending your server side code - return some result that will mean for client side code that need to raise a question and return result to the server
    • saving the state in some type of structure (or by returning the result to the user)
    • ask for input
    • then run new server side code that contains user input (+ data saved from previous server execution)
  • Hello Joseph, Please remember that methods of written using  C# and VB.NET are server side methods. The code is running on the server and not on user computer, as so you can't trigger dialog on the user computer when it executed on the server. The concept of Server-Client development is different than Winforms (or client only). As I'm not familiar with your task, I can only guess that you want to achieve one of the following:
    1. Show Error\Info message box with OK button
    2. Interact with the user - ask a question and then process based on his response
    <h3>Show Error\Info message box with OK button</h3> If you need to return error in Aras you can return from your server side code following result and this will rise dialog with your message:
    return this.getInnovator().newError("YOUR_ERROR_TEXT");
    If you need to return Info dialog that mean something like: "Done - you can keep working", you need to return from your server side code:
    return this.getInnovator().newResult("YOUR_INFO_TEXT OR EMPTY STRING")
    Notice: dependence on configuration this text will not be shown or will be shown as small popup on the left bottom corner of the screen. <h3>Interact with the user - ask a question and then process based on his response</h3> In my opinion if it's possible try to collect as much input as possible before running the server code. If you still need to interact with the user during the execution of the server side code, it only can be done by:
    • ending your server side code - return some result that will mean for client side code that need to raise a question and return result to the server
    • saving the state in some type of structure (or by returning the result to the user)
    • ask for input
    • then run new server side code that contains user input (+ data saved from previous server execution)
  • Hi Joseph, C# is primarily used for communication with the server within Aras Innovator. For all client-side operations, we rely on JavaScript and HTML. I would recommend looking at this blog post if you're just trying to show a simple message to the user or this blog post if you're trying to achieve more complex functionality. Chris
    Christopher Gillis Aras Labs Software Engineer
  • Hi Zahar and Christopher, Thank you so much for your replies.