PDA

View Full Version : [CLOSED] MessageBusDirectEvents with Response.Redirect



ViDom
Dec 03, 2013, 10:26 AM
Hello,
This is my example:

MasterPage


<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="Page.master.cs" Inherits="test2.Page" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void ServerBusEvent(object sender, DirectEventArgs e)
{
X.Msg.Show(new MessageBoxConfig() { Message = "It works!!!: " + e.ExtraParams["message"] });
}
</script>
<!DOCTYPE html>

<html>
<head runat="server">
<title></title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager runat="server" />

<ext:Viewport runat="server" Layout="BorderLayout">
<Items>
<ext:Container runat="server" ID="pane1" Title="Global logger in master page" Height="150" Region="North" Layout="FitLayout">

<MessageBusDirectEvents>
<ext:MessageBusDirectEvent Name="**" OnEvent="ServerBusEvent">
<ExtraParams>
<ext:Parameter Name="message" Value="data" Mode="Raw" />
</ExtraParams>
</ext:MessageBusDirectEvent>
</MessageBusDirectEvents>
</ext:Container>

<ext:Container runat="server" Layout="FitLayout" Region="Center">
<Content>
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</Content>
</ext:Container>
</Items>
</ext:Viewport>
</form>
</body>
</html>


Content


<%@ Page Title="" Language="C#" MasterPageFile="Page.Master"%>
<script runat="server">
protected void click(object sender, DirectEventArgs e)
{
MessageBus.Default.Publish("Msg.Server", "It is an event from server side");
Response.Redirect("Default.aspx"); //after comment out this line, it works
}
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<ext:Container runat="server" Title="Container in content page">
<LayoutConfig>
<ext:VBoxLayoutConfig Align="Stretch" />
</LayoutConfig>
<Items>
<ext:Button runat="server" ID="test" Text="test" Width="100" Height="50">
<DirectEvents>
<Click OnEvent="click"></Click>
</DirectEvents>
</ext:Button>
</Items>
</ext:Container>
</asp:Content>

Is there any way to call MessageBus an redirect in the same DirectEvent?

Daniil
Dec 03, 2013, 11:18 AM
Hi @ViDom,

Anyway, redirection won't wait execution of the ServerBusEvent handler.

The only suitable way is to redirect inside the ServerBusEvent handler or in its Success handler.