asp.net

MVC & Date Formatting

Hi, Where in an MVC based architecture should the date formatting (long/short/time/no-time/UK/US) live? I want to be able to specify long/short/time/no-time on a per-field basis - i.e. DateOfBirth doesn't care about time, but CreationDate might. Using ASP.NET MVC, there doesn't seem an easy way to do it in the View, which makes me won...

Why is my onbeforeunload not running now when it was before? Or AJAX failing on second identical command?

This follows on from this question This was working: <body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=266&UserID=11631');"> This was created using the following in the aspx page: <body onbeforeunload= "ajaxRequest('UnlockQuery.ashx?QueryID=<%= Session["QueryId"] %>& UserID=<%= Session["UserID"] %>')"> This is not wo...

Disable link button after click on it in c#

I want to disable link button after clicking of it & other enable. toggle enable/ disable between both link buttons using c# ...

FSharp site on shared server, which dll's do I need to include in the bin folder?

Which dll's do I need to include in the bin folder? or do I need to install F# on the server it self ? N.B: Resolved All the FSharp dlls are now in the site Bin The site is deployed using the Publish option from Visual Studio The allow precompiled site to be updatable has to be unchecked Error from my site: The system cannot fin...

URL rewriting

I am using regx for URL rewriting. created a XML file and write the below code in Global.ASAX file string sPath = Context.Request.Path; Context.Items["VirtualURL"] = sPath; Regex oReg; System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument(); xmlDoc.Load(Server.MapPath("~/Rule.xml")); System.Xml.XmlElement _oRu...

Keep a large number of objects in memory for a long time

In my ASP.NET app, I have a dictionary that contains a large number of objects (let's say as large as 1M, could get even bigger later), the object stored in the dictionary is of reference type not struct type, the dictionary is meant to work as a cache for this type of objects (I have my reasons not to use the ASP.NET cache for caching t...

Any way to clear/flush/remove OutputCache ?

Hello all, I'm using the OutputCache on my webuser control (.ascx) <%@ OutputCache Duration="1000" VaryByParam="none" %> I would like to retain the cache for next 1000 seconds, but when a specific page on my site is loaded, I would like to remove/flush/refresh the cache. Like, I want to clear the cache when MyPage.aspx is loaded. Can ...

Authorization check using Global.asax

In my ASP.NET web application, I want to check every time the user is trying to get a page from my application if the user exist in the DB (of course after the first time we save the user details in the session). I tried to use the Application_AuthenticateRequest event in the global.asax to check for each request but the session does no...

Validating multi-line text input when using .NET

I have an HtmlTextArea and I want to restrict the number of characters users can input to 500. Currently I've used a RegularExpressionValidator... RegularExpressiondValidator val = new RegularExpressiondValidator (); val.ValidationExpression = "^.{0,500}$"; val.ControlToValidate = id; val.ErrorMessage = "blah"; ... this is fine when ...

How can I get a username and password from my database in C#?

I have the following code in my btn_click event: Sqlconnection con = new Sqlconnection("server=.;database=bss;user id=ab;pwd=ab"); con.open(); SqlCommand cmd = new Sqlcommand("select * from login where username='" + txt4name.Text + "' and pwd='" + txt4pwd.Text + "'", con); SqlDataReader reader = cmd.execute Reader(); Where login is ...

Logging for ASP.NET - Best Practices

What is the best way to write minimal error logs in an ASP.NET 2.0 web page or web service? For my purposes it'd be best if this was vanilla, and the implementation would work through IIS's virtual directories. I'm currently using the standard TextWriterTraceListener, but it doesn't seem to write to the virtual directory. FYI - the Te...

Email Templating with Delimiters

Hi, In DasBlog the template uses the following syntax, for example: <h1><%= MyMacro() %></h1> inside a txt file, and my query is, how this is evaluated at run time? Does the author of DasBlog use the AspCompiler programatically? Is there an Evaluating statement I am missing or is the author simply using Regular Expression search and...

ASP.NET Controls and Update Panels

I am creating a series of client side component controls on the fly that are nested inside a update panel. The first time I create the controls, everything works as desired, however, when i trigger an update on the update panel and it does a partial postback the controls come back with several javascript errors describing how the contro...

Override .Net Resource file in Calling Application

I have an asp.net 2.0 web application that is calling class library. A fairly common scenario to be sure. The class library is making use of a number of resource files and a ResourceManager object to set localised strings. This works absolutely fine in most circumstances based on the user's browser settings. However there are some circ...

Need help databinding an ArrayList of ListItems - .NET 1.1

I am databinding a dropdown list with the following array list: ArrayList al = new ArrayList(); al.Add(new ListItem("Service Types", 1)); al.Add(new ListItem("Expense Types", 2)); al.Add(new ListItem("Payment Terms", 3)); al.Add(new ListItem("Classes", 4)); al.Add(new ListItem("Project", 5)); al.Add(new ListItem("Employees", 6)); al.A...

stopping app_offline.htm from being created and deleted at each build?

I have a solution with 2 projects in Visual Studio 2008 SP1, .NET Framework 3.5 SP1. a ASP Web site. a Class Library (dll) project. I have a reference from the Web Site to the Class Library, as the Class Library is my data layer. But anyway, the thing happens only with this basic setup, a solution with these 2 types of projects and a...

Byte array in Classic ASP

How do I write the following code in classic ASP? I am using this code in an include file. byte[] bytes = new byte[stream.Length] Also it would be great if anyone can say how to create object for StreamWriter in classic ASP. Set sw = Server.CreateObject("System.IO.StreamWriter(stream)") I am not sure about the code inside quotes...

Using CSS in ASP.NET

Hi Friends, I have one question.. I am using Asp.Net C# With SQL 2005 I have one grid in that and in grid i put one image box and i want to call image from my css. when i use ImageUrl="~/Images/delete_link_thumb.gif" at image level then image is good but when i call from css through background-image:url(images/edit_link_thumb.gif); t...

Get last run date of task in Windows Scheduled Tasks from ASP.NET

Is it possible to get the last run date of a scheduled task in Windows Scheduled Tasks from ASP.NET? Ideally, it would be good to be able to list, start and stop these tasks as well, though at this stage, the main thing I'd like to do is retrieve the last run time for a specific scheduled task. If this is not possible, my workaround is...

What is the best study guide for MCTS exam 70-562 ASP.NET 3.5 Application Development?

The official "MCTS Self-Paced Training Kit (Exam 70-562): Microsoft .NET Framework 3.5 ASP.NET Application Development" will not be released until mid-April. For the time being, what is the best book with which to prepare for the exam? I'm not asking which book is the best ASP.NET 3.5 book in general, just which is best with regard to t...