asp.net-3.5

How can we stop web page view after signout using browser back

元气小坏坏 提交于 2019-12-01 03:11:43
问题 I am having web site in ASP.NET. We have two type of login 1. Users 2. Administrator I am facing following problem during testing Problem statement: Suppose i loggedin by user login and surf all pages, let say at any page of user i click on logout button, it will redirect me at login page. Now the problem comes when i use browser back, it shows me user's page But in actual i should not able to view that page after logout. My functionality is proper because if i click on page after logout it

ASP.net DropDownList with no selected item

删除回忆录丶 提交于 2019-12-01 03:07:59
I have a ASP DropDownList with items added to it. All what I want is to make the selection after the page loaded empty so there is no a selected item. How can I do that? You can add an empty item to the top of your dropdownlist programmatically like this: myDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty)); myDropDown.SelectedIndex = 0; Not sure I understand your question but try this: DropDownList1.ClearSelection() or DropDownList1.SelectedIndex = -1; You can set the SelectedIndex property to -1 or you can add an empty entry as the first item in the data source and validate

How to check if a DateTime range is within another 3 month DateTime range

陌路散爱 提交于 2019-12-01 01:54:55
问题 Hi I have a Start Date and End Date per record in a db. I need to check to see where the time period falls in a 2 year period broken into two lots of quarters then display what quarters each record falls into. Quarter 1 includes June 09, Jul 09, Aug 09 Quarter 2 includes Sept 09, Oct 09, Nov 09 Quarter 3 includes Dec 09, Jan 10, Feb 10 Quarter 4 includes Mar 10, Apr 10, May 10 Quaretr 5 includes Jun 10, Jul 10... e.g. 01/10/09 - 01/06/10 would fall into quarters 2, 3, 4 & 5 I am very new to

PDF Previewing and viewing

烂漫一生 提交于 2019-11-30 21:29:52
I'm creating a document viewing web application. You log in and it takes you to a screen where you have all your docs listed on the left. I want to make it so that when you roll over a document a preview of the document shows up on the right. From there you can click on it for a full view and printing capabilities. I'm not asking how to do all that but I'm wondering what the best way would be to go about rendering the preview of the document. The documents are all going to be pdfs and stored on a server. I'm working in asp.net 3.5 mvc in visual studios 2008. Renaud Bompuis For creating the PDF

C#: Changing the order of columns when binding DataTable to a GridView

狂风中的少年 提交于 2019-11-30 17:51:36
问题 How is it possible to change the displayed order of columns from a DataTable? For example, dataTable "dt" contains two columns "a" and "b". I bind it to a GridView like this: gridView.DataSource = dt; gridView.DataBind(); But I'd like the GridView to display "b" first (leftmost). Important point: I'm using this to export to Excel and there's no actual output to screen, using: HtmlTextWriter htw = new HtmlTextWriter(sw); gridView.RenderControl(htw); Thanks! 回答1: yes you can do it in the front

Adding PostBackTriggers and AsyncPostBackTriggers to UpdatePanel for dynamically-generated grandchild controls

喜你入骨 提交于 2019-11-30 14:39:34
I have a page with a ScriptManager, a generic HTML drop-down list ( <select> ), and an UpdatePanel. The UpdatePanel contains a PlaceHolder (for now). During Page_Load, a number of user controls are added to the PlaceHolder (really, it's several instances of the same user control). The number to add is not known until the page loads, so they do need to be loaded dynamically. The drop-down list is populated with the same number of menu items, and there is javascript on the page also (using jQuery) to show only one of the controls at a time depending on the state of the drop-down list. Each user

Asp.net checkbox and html data attribute

£可爱£侵袭症+ 提交于 2019-11-30 11:10:28
In asp.net, if you use a custom attribute, usually it is rendered as-is. Considering this markup ( note: attributes such as id , name and for were removed in all examples as their generated id/names are verbose): <asp:TextBox runat="server" data-foo="bar" /> Is rendered in asp.net as: <input type="text" data-foo="bar" /> That is, asp.net keeps data-foo untouched. Check box are usually rendered like this: <asp:CheckBox runat="server" Text="Normal" /> Renders as: <input type="checkbox" /> <label>Normal</label> But if you add a custom attribute on a checkbox: <asp:CheckBox runat="server" Text=

Validation of viewstate MAC failed when on page for 20+ minutes

那年仲夏 提交于 2019-11-30 09:21:49
If you open a web page on one of the websites hosted on our server, leave it for 20 minutes and then submit a form, a Validation of viewstate MAC failed. error occurs. What possible reasons could there be for this? There's a few reasons this can happen: Auto-Generated Machine Keys: If your application pools have the default idle timeout of 20 minutes AND you're using auto-generated validation and decryption keys then each time the pool starts it will generate a new set of keys. This invalidates the browser's encrypted viewstate. You'll also find that forms authentication tickets for persistent

Can I split system.serviceModel into a separate .config file?

允我心安 提交于 2019-11-30 08:09:21
I want to separate my system.serviceModel section of the web.config into a separate file to facilitate some environment settings. My efforts have been fruitless. When I attempt it using this method. The wcf code throws an exception: "The type initializer for 'System.ServiceModel.ClientBase 1 threw an exception. Can anyone tell me what I am doing wrong? Web.config: <configuration> <system.serviceModel configSource="MyWCF.config" /> .... MyWCF.config: <system.serviceModel> <extensions> ... </extensions> <bindings> ... </bindings> <behaviors> ... </behaviors> <client> ... </client> </system

Linq: Get a list of all tables within DataContext

六月ゝ 毕业季﹏ 提交于 2019-11-30 07:26:30
I have a DataContext (Linq to Sql) with over 100 tables, is it possible to get a list of all those tables and lets say print them to the console? This might be a silly question. Thanks. It's much easier than above and no reflection required. Linq to SQL has a Mapping property that you can use to get an enumeration of all the tables. context.Mapping.GetTables(); You can do this via reflection. Essentially, you iterate over the properties in your DataContext class. For each property, check to see if that property's generic parameter type has the TableAttribute attribute. If so, that property