|
You need one javascript function to capture browser unload event and one hidden server control button with click event. In that javascript function write code to click the hidden button. In the button click event you can do the actions you want like session clean up.
Ex:
//Javascript
javascript:window.onbeforeunload = function(){
if((window.event.clientX<0) ||
(window.event.clientY<0)){
if(document.getElementById("ctl00$testbutton")!=null)
document.getElementById("ctl00$testbutton").onclick();
}
}
//button event
protected void testbutton_ServerClick(object sender, EventArgs e)
{ Session["test"]=null;
Session.Abandon();
}
Hope it helps
|
|
|
|
|
The same thing could be accomplished with an AJAX call and avoiding another postback.
Also, using JQuery to find the DOM elements is more resilient than using getElementById, IMO.
No comment
|
|
|
|
|
Im trying to see if there is a better way of doing something that I have implemented. In our project we have a class that contains alot of generic list properties, for example
public class Portfolio
public property Client as list(of client)
end property
public property Covers as list(of covers)
end property
public property HomeQuotes as list(of HomeQuotes)
end property
end class
All the data is taken from the database using a LINQ to SQL. I have looked at using IoC container but am not sure that they are the best way to go as this container rarely changes in contents.
Any reference materials or that you could point me too or tips that you could give I would be grateful.
Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch
|
|
|
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p style="text-align:right;">
<asp:Button ID="btnAdd" runat="Server" Text="Add New Record" OnClick="AddNewRecord" /></p>
<asp:GridView ID="GridView1" runat="Server" AutoGenerateColumns="False"BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px"CellPadding="4" ForeColor="Black" GridLines="Vertical" SkinID="RecordList" Width="100%"OnRowCommand="GridView1_OnRowCommand1" ShowFooter="False" AutoGenerateEditButton="true" OnRowEditing="EditRecord" OnRowCancelingEdit="CancelRecord"OnRowUpdating="UpdateRecords" DataKeyNames="AutoID" EnableViewState="True">
<Columns>
<asp:BoundField DataField="AutoID" HeaderText="AutoID" ReadOnly="True" />
<asp:TemplateField HeaderText="UserName">
<ItemTemplate><%# Eval("UserName") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtUserName" runat="Server" Text='<%# Eval("UserName") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate><asp:TextBox ID="txtNewUserName" runat="Server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Password">
<ItemTemplate><%# Eval("Password") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtPassword" runat="Server" Text='<%# Eval("Password") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate><asp:TextBox ID="txtNewPassword" runat="Server"></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SuperPassword">
<ItemTemplate><%# Eval("SuperPassword") %></ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtSuperPassword" runat="Server" Text='<%# Eval("SuperPassword") %>'></asp:TextBox></EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewSuperPassword" runat="Server"></asp:TextBox></FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="UserType">
<ItemTemplate><%# Eval("UserType") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropType" runat="server" SelectedValue='<%# Eval("UserType").ToString() %>'>
<asp:ListItem Text="Admin" Value="Admin"></asp:ListItem><asp:ListItem Text="Maint" Value="Maint"></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="NewdropType" runat="server">
<asp:ListItem Text="Admin" Value="Admin">
</asp:ListItem><asp:ListItem Text="Maint" Value="Maint">
</asp:ListItem></asp:DropDownList>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="AdminDesc">
<ItemTemplate><%# Eval("AdminDesc") %></ItemTemplate>
<EditItemTemplate><asp:TextBox ID="txtAdminDesc" Columns="30" runat="Server" Text='<%# Eval("AdminDesc") %>'>
</asp:TextBox></EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtNewAdminDesc" runat="Server" Text='<%# Eval("AdminDesc") %>'></asp:TextBox>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Active">
<ItemTemplate><%# Eval("Active") %></ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="dropActive" runat="server" SelectedValue='<%# Eval("Active").ToString().ToLower().Equals("true") ? "True" : "False" %>'><asp:ListItem Text="Yes" Value="True"></asp:ListItem><asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList></EditItemTemplate>
<FooterTemplate><asp:DropDownList ID="dropNewActive" runat="server"><asp:ListItem Text="Yes" Value="True"></asp:ListItem><asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList> <br />
<asp:Button ID="butIns" runat="Server" Text="Insert" CommandName="Insert" UseSubmitBehavior="False" /></FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#CCCC99" /><RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" /><HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
<EmptyDataTemplate>UserName
<asp:TextBox ID="txtUserName2" runat="Server"></asp:TextBox> Password
<asp:TextBox ID="txtPassword2" runat="Server"></asp:TextBox> SuperPassword
<asp:TextBox ID="txtSuperPassword2" runat="Server"></asp:TextBox> User Type
<asp:DropDownList ID="dropType2" runat="server">
<asp:ListItem Text="Admin2" Value="Admin"></asp:ListItem>
<asp:ListItem Text="Maint" Value="Maint"></asp:ListItem></asp:DropDownList> Admin Desc
<asp:TextBox ID="txtAdminDesc3" runat="Server" /> Active
<asp:DropDownList ID="dropActive3" runat="server">
<asp:ListItem Text="Yes" Value="True"></asp:ListItem>
<asp:ListItem Text="No" Value="False"></asp:ListItem></asp:DropDownList>
<asp:Button ID="btnInsert" runat="Server" Text="Insert" CommandName="EmptyInsert" UseSubmitBehavior="False" />
</EmptyDataTemplate>
</asp:GridView>
</div>
</form>
</body>
</html>
|
|
|
|
|
This really belongs into the ASP.NET forum and it should also contain code-formatting tags (see the link code above the editing textbox).
Regards,
Manfred
"With sufficient thrust, pigs fly just fine."
Ross Callon, The Twelve Networking Truths, RFC1925
|
|
|
|
|
I am not .Net developer. I am just curious.
First of all, as far I understand .Net is suppose to be platform independent. That is why it compile targeting (I think I read somewhere) a Virtual processor.
Now if a developer use WIN32 API in there .Net Application will it be plat form independent at all? I believe no it wont be. Then what is the real purpose of developing a .Net application that would take too much memory, and make my old machine tired?
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
.NET is NOT platform independent. .NET is Microsofts implementation of the Common Language Infrastructure (CLI - which Microsoft wrote BTW) for Windows. Mono is another open source implementation of the CLI for Linux. General code that doesn't use any implementation specific libraries should work on any implementation.
When you start getting into the implementation specific stuff, like WPF in Windows, of course that's not going to work on Mono because Linux doesn't have WPF.
Any code you write that P/Invokes Win32 functions, obviously, will not work on anything other than a version of Windows that implements those functions.
|
|
|
|
|
Then why so called new technology, that will make my computer slow and after sometime it will tell me i am backdated upgrade yoursef?
I know I am coward since the day I know that fortune favors the brave
|
|
|
|
|
johny10151981 wrote: that will make my computer slow
Uhhh, no it won't. Where are you getting THAT from??
johny10151981 wrote: and after sometime it will tell me i am backdated upgrade yoursef?
No, it won't. Again, you seem to have some misconceptions on what .NET is and how it works.
|
|
|
|
|
johny10151981 wrote:
First of all, as far I understand .Net is suppose to be platform independen
No. .Net is not platform independent.
johny10151981 wrote: Now if a developer use WIN32 API in there .Net Application will it be plat form independent at all?
It won't be platform independent.
Simply put, Win32 API code never run on a MAC.
|
|
|
|
|
Hi,I am working on a project to manage information of our faculty from ASP.net in C#.
There are profiles for lecturer,student and department head.When Admin set privileges to do tasks Eg:edit student details, this should be appear only in the lecturer profile as a links to edit those data.
So, I want to create the admin page with ability to do those tasks and I have no idea to do that .Can you please give ideas,links or tutorials.
Thanks.
|
|
|
|
|
You may get a faster response if you move this question to the correct forum[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks
|
|
|
|
|
pimzy wrote: Can you please give ideas,links or tutorials.
There's always MSDN[^].
Bastard Programmer from Hell
|
|
|
|
|
Thanks i read the link .But how can i make admin page to appear a link in profiles(when admin set privileges for a particular task)
Are there any way to do that?
|
|
|
|
|
As discussed in the link; if the user is in the admin role, display the link.
Bastard Programmer from Hell
|
|
|
|
|
Hello,
i am pursuing MCSD. I want to know which books should i refer???
Which books are easier to understand?
◘ "Everyone wants results, but no one is willing to do what it takes to get them" - Dirty Harry ◘
► In Life go Straight, And turn Right ◄
|
|
|
|
|
|
how to insert drop down list in gridview
|
|
|
|
|
Add a Dropdownlist inside an ItemTemplate .
This[^] should help you out.
|
|
|
|
|
Hi,
my WCF service is running with threads, based on the ID value(for every ID value from database one thread will start when service starts), I want to pause a thread some time, and restart again.
End user will press the Button from the webapplication, then ID will pass to the WCF service. then that thread has to pause and restart.
Please help me, if any one knows,
Thanks in advance
Murty
|
|
|
|
|
dwadasi wrote: want to pause a thread some time, and restart again.
The thread Suspend method is now obsolete.
However, you can consider using the ManualResetEvent class for this kind of operations.
Be sure to ensure data is locked during such type of operations.
|
|
|
|
|
dwadasi wrote: my WCF service is running with threads, based on the ID value(for every ID value from database one thread will start when service starts), I want to pause a thread some time, and restart again.
What happens if they never restart it?
What happens if the server bounces (stop then start) after the user pauses it?
|
|
|
|
|
|
This is the wrong forum. If you want some reasonable feedback then write an article and post it for publication as described in the guidelines[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|