A pop up window from a C# code behind

G

Guest

I'm a little surprised. I tried to search for a way to open a modal dialog
using c# in a code behind file but couldn't really find it. I know there is a
way to do it, but I guess I'm still struggling learning the help system.

Here is the deal. I am writing web based front ends. I'm right now writing
my error handler. It's designed to be quite powerful but for now all I want
to do is pop up a modal window to which I can pass an error message. That's
all.

Could someone point me in the right direction please?
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

you cannot do that from the code behind, that code is executed 100% in the
server, not in the client.
what you can do is send the code to the client to do so, define a JScript
function that open the windows as you want it and simply put the code to
call this method, there are several ways of doung it , like:

<scrupt>
function Callme( msg)
{
alert( msg );
}
</script>
<body runat=server id=theBody>

in the code behind

HtmlGenericControl theBody;

if ( somecondition)
theBody.AddAttribute( "onclick", "Callme('some error msg');");

}

cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top