asp.net

How do I know if I'm running in a web environment?

I'm wondering if someone has a method for detecting whether or not a thread is running in a web environment. HttpContext.Current is not reliable because I'm making these checks in background threads where there is no HttpContext. It seems like HttpRuntime.AppDomainAppId is pretty reliable (if it is null then I'm not in a web app), ...

Best practice for managing/generating policy numbers

I am currently working on a website which allows a prospect to generate a quote and purchase a policy. After they submit their payment the application should generate a policy number. I was given a block of policy numbers to use incrementally. For this example, let's say 0100800 - 0100999. If I have two or more people who decide t...

Populate DropDownList from DataSource (ASP.NET)

I have an SQL Data Source which selects all rows of a table. I need to populate a dropdownlist with a certain field ('percentage') of all the rows, and when one is clicked to make the 'value' the rows 'id' field. Is there a simple way of doing this? Thanks ...

Multiple contact forms within a .NET page

Tearing my hair out here trying to implement a pretty simple form inside a .NET page. The form looks like this: <form action="http://domain.com/subscribe.tml" method="POST"> <p><input name="email" type="text" /></p> <p><input type="image" src="/images/ui/btn-getfreereport.gif" alt="Signup" /> </p> <input type="hidden" value="one_he...

Configure ASP.NET Session State at runtime

We have an ASP.NET web site that uses SQL Server session state. The state is configured in Web.config like: <sessionState mode="SQLServer" sqlConnectionString="data source=TheServer; User ID=TheUser;password=ThePassword;" cookieless="false" timeout="480"/> But there are three environments (development / staging / production). Al...

How can I store the actual control in a list?

Long story short, I would like to take my usercontrols that are loaded dynamically and stick them into a list that references the actual object that has been loaded. So I can go into the list and pull results from the usercontrol. I would like to use mycontrol.GetResult() and it will then reference the control and grab the results from t...

URL's not being resolved when in UserControl (ASP.NET)

If I pass the derived class testA a PlaceHolder that contains a Hyperlink, with a url that starts with a tilde, it resolves it correctly. However, when I pass testB (identical apart from it inherits from System.Web.UI.UserControl) the same PlaceHolder It renders it literally (doesn't transform / resolve the '~') Any ideas? publi...

What is the maximum length of html textbox

can anyone help me with the length of maximum characters that can be contain in a normal HTML text box.... ...

Using AutoCompleteExtender advice

I have an AutoCompleteExtender in my ASP.NET which works great so far. I have a few little niggles I'd like to sort out though: 1: Is there a way I can limit the user to only being able to select an item from the list, and not use their own text? So they can't search for something that isn't autocompleted. 2: Is there a way to always h...

using html.ActionLink but not html encoding

I wish to return the following output <a href="#"><img src="/images/icons/tick.png" alt="" />More info</a> If i do the following the content is html encoded. <%= Html.ActionLink("<img src='/images/icons/tick.png' />More info", "OrderRegion", "Campaign", new {id = Model.Campaign.Id}, null) %> How can i disable the html encoding? ...

Event log has an error. "An unhandled exception has occurred"

Hello, I am using Visual Studio 2005 and IIS 6.0.. I have this warning in the event log. I am trying to find what it is. I have never went through this exception when i am working. What can be done and where can be done to not get the exception warning again. Thanks so much in advance!! Event code: 3005 Event message: An unhandled exc...

Injecting a service into an implementation of NHibernate's IUserType using Autofac.

I'm using NHibernate to map the following class to an Oracle database in my ASP.NET MVC application: public class User { // Needs to be encrypted/decrypted when persisting public virtual string Question { get; set; } } Following several examples that I've found, I would like to use an implementation of NHibernate's IUserType t...

Eval/Bind TimeOfDay property without milliseconds?

Hi all, I'm trying to format the following: <%# Bind("TimeOfDay","{0:HH:mm:ss}") %> <%# Eval("TimeOfDay","{0:HH:mm:ss}") %> <%# Bind("TimeOfDay","{0:HH:mm:ss tt}") %> But using either of those returns time as following: 08:33:08.1430000 How can I only get the 08:33:08 part? Thanks, EtonB. ...

What's the easiest way to create a feed in asp.net?

I want to provide some dynamic content like an rss feed, so when they go to mydomain.com/fishcake.rss it runs some code on the server to generate it and returns it back. I am guessing maybe an ashx file and something in the webconfig to associate it with the path I want, but I'm not totally sure. Can you help? ...

Web app works in Firefox but not IE8

I've built this app that displays employee photos stored in several sharepoint folders. It also displays the employee name extracted from the file name and a previous and next button to move through the photos. The markup is surrounded by an update panel to prevent the entire page from reloading when you click to view the next photo. ...

How to allow mixed-mode authentication in IIS 7.0

How do you back-door authenticate Windows users into a website using forms authentication running on IIS 7.0? ...

Entity Framework and Linq - Comparing DateTime

I have this code public List<CalendarData> GetCalendarData(DateTime day) { List<CalendarData> list = new List<CalendarData>(); using (dataContext = new VTCEntities()) { DateTime test = new DateTime(2010, 10, 20, 17, 45, 0); var data = from z in dataContext.ReservationsSet ...

Getting strange error trying to run an ASP.NET app in VS 2008

I've upgraded a VS 2005 app to VS 2008, and tried to run it. I get some very strange behavior. Something, I don't know what, comes up and says: "Unable to start debugging on the web server. <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd <html xmlns="http://www.w3.org/1999/xht...

How to localize WebParts attributes within the PropertyEditorPart?

Is there any way to localize the text displayed within the PropertyEditorPart? [Personalizable(true), WebBrowsable(true), WebDisplayName("To Date: "), WebDescription("Please enter To Date value.")] public string ToDate { get { return toDate; } set { toDate = value; } } ...

Does this regex expression allow "*"?

I really know very little about regex's. I'm trying to test a password validation. Here's the regex that describes it (I didn't write it, and don't know what it means): private static string passwordField = "[^A-Za-z0-9_.\\-!@#$%^&*()=+;:'\"|~`<>?\\/{}]"; I've tried a password like "dfgbrk*", and my code, using the above regex,...