iSeller Commerce
iSeller POS Retail
iSeller POS F&B
iSeller POS Express
Crosslight
WebUI
ClientUI
What's New
Download Trial
Web Solution
Mobile Solution
Enterprise Solution
Custom Development
Blog
Community
Latest Development Blogs
ForumPostTopic
Browse By Tag
Hello,
I'm trying to figure out how to prevent the "OnClicked" event(server side) of a WebButton
from within some inheritted base page (On_Init event) in case session has ended, and actually redirect the user into another page without allowing the event to fire.
I have tried Response.Redirect and even Page.ClientScript.RegisterClientScriptBlock prior to invoking the event, but nothing seemed to work. I believe something is interfering with FlyPostBack mechanism(?)
Help would be much appreciated!
I'm using the following control & code:
<ISWebDesktop:WebButton ID="bttn" runat="server" Height="20px" Width="150px"
Text="Click" DisplayMode="Text" AutoPostback="true" TabIndex="108"
OnClientClick="bttn_OnClientClick" OnClicked="bttn_OnClicked">
<FlyPostBackSettings PostHiddenFields="True" PostInputControls="True" />
</ISWebDesktop:WebButton>
protected void bttn_OnClicked(object sender, WebButtonClickedEventArgs e)
{
...
bttn.ClientAction.InvokeScript("JSFunc();");
}
function bttn_OnClientClick(controlId) { return false; }
This will cancel your OnClick event in server side. Hope this helps.
Regards,Bernard
Bernard Hi,
Thank you very much for your kind answer. Though it is not quite what I ment.
I'd like to check session availability on server side (using inherited page base), for all intersoft's controls that use FlyPostBack, without actually checking session for each event.
In case the session has ended, I would like to cancel the AJAX request made by the flypostback, and redirect the user to login page.
Is there a way to actually cancel the AJAX request and inject a javascript redirection?
Hi Roi,
I think you could do this scenario with session timeout. However, you should check this session on Page_Load event because it will call Page_Load event even when the page do FlyPostback. You can check if the session still available and redirect it to login page when the session is over. Also, you could do flypostback method from client side to request the session in server side. You can also redirect the page in client side. Hope this helps.
Barnard Hi,
Page_load would not work, neither by using Response.Redirect or by adding a redirect javascript function for that matter, simply because the flypostback occurs behind the scene.
You must attach a javascript function to the control by using:
WebButton.ClientAction.InvokeScript("Redirect()");
Since I need it to occure for every WebButton that does a flypostback, I need to overried the it's Click event in the base page.
Any suggestions how I do that?
Sorry for my misunderstanding. I think the response.redirect only can be used when you are in fullpostback mode. However, you could achieve this scenario in client side. In OnClientClick you could request the session in server side and save it to a hidden field in your page. Then using window.location attribute, you could redirect when the session is over. To get this session in server side your could use our WebFlyPostBackManager or you could do Ajax request to server. Hope this helps.
I think there are no other way than redirect the page using InvokeScript method that you mentioned before. Perhaps, you doesn't need to check it in all OnFlyPostback event of our control that you used in your page because you could add this validation on Page_Load event. Everytime our control do Flypostback, it needs to return the parameter to its page. So it will be better if you redirect the page in client side because it won't bother the FlyPostback mechanism to return the parameter.
I also attach my sample here. Hope this helps.
For some reason I am not able to use the link you have sent me.
Do you happen to know of a way to dynamically OVERRIDE the "OnClicked" event of each WebButton control? For example, I can use this function to override each OnLoad event of each page:
protected override void OnLoad(EventArgs e){
base.OnLoad(e);}
Overriding the "OnClicked" event could be very helpful.
I think you could validate the session when flypostback in Page_Load event.
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { //you can validate the page session in here and call the response from here WebButton1.ClientAction.InvokeScript("Redirect()"); WebButton2.ClientAction.InvokeScript("Redirect()"); WebButton3.ClientAction.InvokeScript("Redirect()"); WebButton4.ClientAction.InvokeScript("Redirect()"); } }
Page_Load event will be called during postback in postback cycle. It will be better if you put the validation in there. However, when doing flyposyback the page need to get the responses from Server side. With the method above, the javascript will be called right after the response has been by the page. Hope this helps.
You can download the file from my SkyDrive here: https://skydrive.live.com/redir?resid=F226E4DAA368F2A6!317&authkey=!AFYTwg_yj77uUYk&ithint=file%2c.zip
or
Choose this if you're already a member of Intersoft Community Forum. You can link your OpenID account to your existing Intersoft Social ID.
Choose this if you don't have an Intersoft account yet. Your authenticated OpenID will be automatically linked to your new Intersoft account.
Enter your Wordpress Blogname