PDA

View Full Version : [CLOSED] first alert a message then a few second later(3 second) redirect to another url?



hdsoso
Apr 07, 2014, 3:21 PM
first alert a message then a few second later(3 second) redirect to another url?
how to do this using ext.net?

geoffrey.mcgill
Apr 07, 2014, 6:05 PM
first alert a message then a few second later(3 second) redirect to another url?
how to do this using ext.net?

There are options. The following sample demonstrates one technique.

Example


<%@ Page Language="C#" %>

<script runat="server">
protected void Button1_Click(object el, DirectEventArgs e)
{
X.Msg.Alert("Title", "Hello World").Show();

X.AddScript(@"Ext.Function.defer(function () {
window.location = 'somewhere.aspx';
}, 3000);");
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
</form>
</body>
</html>

Hope this helps.

geoffrey.mcgill
Apr 07, 2014, 6:52 PM
We have added new a new X.Defer() Method and .Defer functionality to the JFunction class.

If you update from Svn, or the upcoming 2.5.1 release, all the following functionality will be enabled.

Example


<%@ Page Language="C#" %>

<script runat="server">
protected void Button1_Click(object el, DirectEventArgs e)
{
// Option 1 - New X.Defer() Method
// Pass in a Hander, or client-side Function name, and the delay value in Milliseconds

var handler = "window.location = 'default.aspx';";

X.Defer(handler, 3000);


// Option 2 = New X.Defer() Method with client-side function name
// Pass in a client-side function name, and the specify the delay in Milliseconds

var fn = "doSomething";

X.Defer(fn, 3000);


// Option 3 - New X.Defer() Method JFunction
// Pass a JFunction to .Defer, and specify the delay in Milliseconds
var func = new JFunction
{
Handler = @"window.location = 'default.aspx';"
};

X.Defer(func, 3000);


// Option 4 - Call .Defer on a JFunction
new JFunction
{
Handler = "window.location = 'default.aspx';"
}.Defer(3000);
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Ext.NET Example</title>

<script type="text/javascript">
var doSomething = function () {
window.location = 'default.aspx';
};
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Button runat="server" Text="Submit" OnDirectClick="Button1_Click" />
</form>
</body>
</html>


Hope this helps.