We help IT Professionals succeed at work.

ASP.NET System.Windows.Forms.MessageBox

Hi,
Is there any downsides/problems adding a reference to System.Windows.Forms and using MessageBox on an ASP.NET form?

Many Thanks,
Comment
Watch Question

Commented:
I don't think it will work. MessageBox is for windows forms and not for web forms
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
you just can't. even if you try on your development PC and it appears to work, don't forget that when it will run on the IIS server, that code which is in the code behind and thus will show ... on the server!
Serdar DemirkolApplication Developer & DBA

Author

Commented:
The reason I want to use Wndows.MessageBox (as it does work); it is easy to take the client response and all happenning on client side.
Does anyone know any better way to take client response other than js alert and confirm as you cannot custimize these two.

Thanks,
Éric MoreauSenior .Net Consultant
Top Expert 2016

Commented:
in the web world, alert is the way to go!
As you mentioned, to get response in Jaavscript Alert and Confirm are the only two options available. Prompt to ge the value from User.

Take a look in to the below sample with the clear explanation
http://sislands.com/jscript/week1/dialogbox.htm
Serdar DemirkolApplication Developer & DBA

Author

Commented:
santhimurthyd:

Any ideas of picking the client response by server dinamically?

Thanks,
If you wish to trigger any event on Server side based on User input, that can be achieved by below stesp

i) Create an asp button
<asp:Button ID="Button1" runat="server" Text="Button" Style="display:none" OnClick="Button1_Click" />

ii) Create an event in the code behind

protected void Button1_Click(object sender, EventArgs e)
{
 //Your logical code you wish to do
}

iii) In the javascript

if(confirm("Are you wish to do"))
{
 document.getElementById("<%=Button1.ClientID %>").click();
}

check it out, whether it meets your requirment
Serdar DemirkolApplication Developer & DBA

Author

Commented:
I have also found below link very useful. Many Thanks

http://www.4guysfromrolla.com/articles/021104-1.aspx
Serdar DemirkolApplication Developer & DBA

Author

Commented:
I've requested that this question be closed as follows:

Accepted answer: 250 points for santhimurthyd's comment http:/Q_27480134.html#37243395
Assisted answer: 250 points for santhimurthyd's comment http:/Q_27480134.html#37243502
Assisted answer: 0 points for serdardmrk's comment http:/Q_27480134.html#37244698

for the following reason:

The link I have provided is exactly what I was looking for so everyone has similar issues would find it as the solution.
I posted same link in my first post, did you read that comment ???
Thanks serdardmrk for accepting the information and for your points.
Serdar DemirkolApplication Developer & DBA

Author

Commented:
ajaysharmaapjs:

Sorry (blaming the busy work), this must be where I have found it. I'll correct the points.