asp.net-3.5

How to catch HttpRequestValidationException in production

佐手、 提交于 2019-12-18 02:18:12
问题 I have this piece of code to handle the HttpRequestValidationException in my global.asax.cs file. protected void Application_Error(object sender, EventArgs e) { var context = HttpContext.Current; var exception = context.Server.GetLastError(); if (exception is HttpRequestValidationException) { Response.Clear(); Response.StatusCode = 200; Response.Write(@"<html><head></head><body>hello</body></html>"); Response.End(); return; } } If I debug my webapplication, it works perfect. But when i put it

CheckBox inside ListBox

岁酱吖の 提交于 2019-12-17 21:33:07
问题 How to add checkbox inside the listbox. Where ChechBoxList controls is not good for more records, By using listbox user can easily scroll to choose the item. Geetha. 回答1: What you want is the CheckBoxList. Newer CheckBoxList Pretty nice step-by-step here. 回答2: what about checkedListBox ? <asp:CheckBoxList id="checkboxlist1" runat="server"> <asp:ListItem>Item 1</asp:ListItem> <asp:ListItem>Item 2</asp:ListItem> <asp:ListItem>Item 3</asp:ListItem> </asp:CheckBoxList> To access items on user

log4net - Appenders not working in IIS7.5

99封情书 提交于 2019-12-17 06:44:04
问题 I am able to write to a log file using log4net and Cassini/IIS dev server, but when I use IIS7.5, I can't write out to a file. Initially, I got a security exception, so I added requirePermission="false" and the exception went away but no file was created. The trust level is full according to IISM. I can't get this working on my own machine, I'm wondering what's going to happen when I transfer to an ISP (discountASP). Here's the log4net setup: <configSections> <section name="log4net" type=

Forms Authentication Timeout vs Session Timeout

和自甴很熟 提交于 2019-12-17 02:26:58
问题 In my asp.net website i am using asp.net form authentication with following configuration <authentication mode="Forms"> <forms loginUrl="~/Pages/Common/Login.aspx" defaultUrl="~/Pages/index.aspx" protection="All" timeout="30" name="MyAuthCookie" path="/" requireSSL="false" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" > </forms> </authentication> I have following questions What should be timeout value for session because i am using sliding expiration inside form authention due

Asp.Net - Redirect if JavaScript is not enabled

瘦欲@ 提交于 2019-12-14 03:08:45
问题 I got this code in my Master page : <script type="text/javascript"> $("#<%=hfJavaScriptDetected.ClientID %>").val('yes'); </script> <asp:HiddenField ID="hfJavaScriptDetected" runat="server" Value="no" /> So if JavaScript is enabled the value of my hidden field should have be changed. Now, what I would like to do is check this value on server side and if it's set to "no", I want to redirect the user to the page Javascript.Aspx. I don't know in which event to look the hidden field value. I try

Using Linq To Convert ListBox Items Values to int

南楼画角 提交于 2019-12-13 16:57:57
问题 I display the contents of a table in the database using a ListBox. Each listbox item is populated with the Text property set to a friendly name, and the Value property set to the unique ID column. The database structure might look similar to the following: CREATE TABLE GENERIC { FRIENDLY_NAME TEXT, ID INT } I tried for almost an hour to convert the items of the listbox to an int[] using LINQ and ultimately failed. It is also important to distinguish between the selected and not selected items

How to add Item to SqlDataSource databound list

我怕爱的太早我们不能终老 提交于 2019-12-13 12:38:56
问题 I am lazy - and I am using a SQLDataSource to populate my dropdownLists. The Databind event for the databound objects is called before the Page.PreRender so I am doing something like this in the PreRender eventHandler: private void InitializeDropDown() { this.myDropDown.Items.Insert(0, new ListItem("-- Select something --")); } I know I can set AppendDataBound items to true and hardcode my custom item in the markup but before reverting to that I'd like to understand why what I am doing is not

How to stop user from changing querystring

那年仲夏 提交于 2019-12-13 12:29:24
问题 How do I protect the url from a user changing one of the param/value pairs? Thanks. 回答1: You can add an HMAC hash of the querystring using a secure random key stored only on the server, then verify the hash on every request. 回答2: You can't. You need to validate them. You should make sure your page accepts only valid input for each of the parameters. "Valid" may mean many things, like "Does the user have access to view this" and so on. 回答3: You could encrypt them or hash them and persist the

Why won't this work as an IIF function, but will as an IF Statement?

扶醉桌前 提交于 2019-12-13 03:39:43
问题 The following works: If 1=1 rdoYes.checked = True Else rdoNo.checked = True End If However, the following doesn't work: IIF(1=1, rdoYes.checked = True, rdoNo.checked = True) Why is this? Thanks! 回答1: It does "work"; it just doesn't do what you want. IIf in VB.NET is a function (don't use it, ever, by the way), which takes these parameters: A Boolean condition to check An Object to return if the condition is True A different Object to return if the condition is False In your usage, your

Data binding controls in asp.net

血红的双手。 提交于 2019-12-13 01:07:50
问题 I have to display a set of data in the following manner: Which ASP.NET 3.5 control best matches my requirement? If one matches, could you please give me an idea about how to format it to view like the image? 回答1: Well, first off you have multiple blocks (multiple rows) so I would suggest a Repeater. Within each block you must display three columns (the image the text and the small images), and you should use a Panel (renders as a ). In the second panel you have multiple lines of text for