|
Saturday, December 29, 2007 |
| ASP.NET Configuration menu item missing |
|
I responded to a user recently on a forum regarding a missing menu item in Visual Studio 2005. The user wanted to create an administrator account using the ASP.NET Configuration tool available through the Website menu. However, the tool was not there. The person was accessing the website directly through ftp in Visual Studio.
What I found is that if you load up a website in VS or VWD using ftp, the ASP.NET Configuration tool is not present on the menu. This is because the tool can only be used on the local system; it can't be used over the web.
If you're trying to manage users over the web, check out my web-based user management sample from my downloads section. |
jeremy at 11:50 AM |
(12) Comments |
Add a comment |
Permalink
|
|
|
Wednesday, September 05, 2007 |
| SQL Server @@IDENTITY vs SCOPE_IDENTITY() |
|
Be careful when using @@IDENTITY or SCOPE_IDENTITY() for returning the last Identity entered in a table. It's important to note how these work
Using SELECT @@IDENTITY is going to return the last Identity value created in any table on the current connection. So if you're using this in a Stored Procedure, and are expecting to get the Identity of a record you just inserted, you could get the id of an insert on another table if it happens on the same connection, for example from a trigger. SELECT @@IDENTITY is limited to the current session.
Using SELECT SCOPE_IDENTITY() will return the last Identity value created in any table on the current connection. In addition, it's limited to the current session and scope. |
jeremy at 9:56 AM |
(7) Comments |
Add a comment |
Permalink
|
|
|
Tuesday, September 04, 2007 |
| Error validating the default for column ... |
|
I made this mistake when I was creating a new table in one of my databases today.
When setting a default for a DateTime column in a SQL Server database, you'll get the error, Error validating the default for column 'column name', if you try something like Now() as the default. That's because that is not a valid function. You need to use GetDate(). |
jeremy at 3:51 PM |
(4) Comments |
Add a comment |
Permalink
|
|
|
Sunday, August 26, 2007 |
| Publishing your database to GoDaddy using Microsoft SQL Server Database Publishing Wizard |
|
|
|
Wednesday, May 09, 2007 |
| Get the file name of the current page in ASP.NET |
|
Here is a nice piece of code to get the file name of the current page that is being viewed. For the purpose of illustration, I'm using some altered code from one of my web applications. This code is being used in the master page to set a session variable only when I'm on a certain content page.
If System.IO.Path.GetFileName(HttpContext.Current.Request.FilePath).ToLower = "secure.aspx" Then Session.Item("MyVariable") = "window_onload();" Else Session.Item("MyVarible") = "" End If If I'm on any other page, I want the session variable cleared. |
jeremy at 1:34 PM |
(32) Comments |
Add a comment |
Permalink
|
|
|
Sunday, November 26, 2006 |
| Error: This row already belongs to another table |
|
I came across this error the other day when I tried to loop through the rows in a Datatable and add some of the rows to another DataTable. Obviously I wasn’t doing what I wanted to do, the right way. What I discovered is that you can’t just add rows from one DataTable to another. First the table structure must be cloned and then the row has to be imported.
Cloning the DataTable clones the structure including all DataTable schemas and constraints. Take a look at the following code.
Dim dtCustomers As DataTable = Session.Item("Customer") Dim dtActiveCustomers As New DataTable dtActiveCustomers = dtCustomers.Clone() For Each row As DataRow In dtCustomers.Rows If CStr(row.Item("Active")) = "1" Then dtActiveCustomers.ImportRow(row) End If Next
In my code example above, I’m carting around a session object of a DataTable of customers. I want another DataTable with only the customers that are active. So I declare a new DataTable and set it to a clone of the Customer DataTable. Dim dtCustomers As DataTable = Session.Item("Customer") Dim dtActiveCustomers As New DataTable dtActiveCustomers = dtCustomers.Clone()
Then I loop through and import the rows where the Active column is equal to 1.
For Each row As DataRow In dtCustomers.Rows
If CStr(row.Item("Active")) = "1" Then
dtActiveCustomers.ImportRow(row)
End If
Next
This example is just a fictional scenario of how cloning a DataTable could come in handy. Whether or not it is the best case for performance as apposed to just hitting the database to fill another DataTable, I’m not sure. I have web applications that hit databases over the internet and it would probably be faster to use the technique above than to make a call to the database over the web.
Thanks to Paul Marshall for his post on this topic. You can view his C# version of cloning a DataTable here. |
jeremy at 1:53 PM |
(6) Comments |
Add a comment |
Permalink
|
|
|
Thursday, November 09, 2006 |
| Run multiple versions of Internet Explorer side by side |
|
I recently downloaded the latest version of the Telerik r.a.d.controls Suite. In the latest version, Q3 2006, it appears that Telerik made some compatibility changes for Internet Explorer 7. However, after I upgraded some of the controls in one of my projects, I was getting some visual anomalies from the controls. This led me down the road of wanting to see how the controls rendered in Internet Explorer 6.
I went on out to Microsoft’s site and found IE 6, but when I tried to download and install it, I received a message box that a newer version was already installed. Now as a web developer, it is a must to be able to see how my web sites render in different versions of a browser. I’m not sure why Microsoft doesn’t support this straight away. It seems to me to be a no-brainer.
Anyhow, I did some searching and found this very useful download at TredoSoft.com, which will allow you to install any combination of IE 3 thru 6 after you have already upgraded to IE 7. |
jeremy at 4:39 PM |
(2) Comments |
Add a comment |
Permalink
|
|
|
Thursday, October 05, 2006 |
| Ping Technorati using VB.NET in ASP.NET |
|
As I recently have explored the world of blogging, I found myself looking for code that would allow me to ping sites like Technorati.com and Feedburner.com. What I found was a nice piece of code in C# by Will Asrari. You can view the C# version of this code at http://www.willasrari.com/blog/programmatically-ping-technorati-using-c/00098.aspx.
However, I program in VB.NET so I converted the code and added the ability to ping several services. The following code will allow you to ping Technorati as well as the other links that are listed. All you need to do is add a call to the procedure in your submit or save event for blog entries.
Public Shared Sub PingSites() Dim listToPing As New ArrayList Dim pingURL As String = "" Dim blogURL As String = "http://www.jeremywadsworth.com" Dim blogName As String = "Jeremy Wadsworth"
With listToPing .Add("http://rpc.technorati.com/rpc/ping") .Add("http://api.feedster.com/ping") .Add("http://ping.feedburner.com") .Add("http://blog.goo.ne.jp/XMLRPC") .Add("http://ping.blo.gs/") .Add("http://ping.bloggers.jp/rpc/") .Add("http://ping.blogmura.jp/rpc/") .Add("http://ping.cocolog-nifty.com/xmlrpc") .Add("http://ping.syndic8.com/xmlrpc.php") .Add("http://rpc.blogbuzzmachine.com/RPC2") .Add("http://rpc.blogrolling.com/pinger/")
End With
For i As Integer = 0 To listToPing.Count - 1 Try pingURL = listToPing.Item(i).ToString Dim technoratiPing As HttpWebRequest = CType(WebRequest.Create(pingURL), HttpWebRequest) technoratiPing.Method = "POST" technoratiPing.ContentType = "text/xml" Dim streamPingRequest As Stream = CType(technoratiPing.GetRequestStream, Stream) Dim xmlPing As XmlTextWriter = New XmlTextWriter(streamPingRequest, System.Text.Encoding.UTF8) xmlPing.WriteStartDocument() xmlPing.WriteStartElement("methodCall") xmlPing.WriteElementString("methodName", "weblogUpdates.ping") xmlPing.WriteStartElement("params") xmlPing.WriteStartElement("param") xmlPing.WriteElementString("value", blogName) xmlPing.WriteEndElement() xmlPing.WriteStartElement("param") xmlPing.WriteElementString("value", blogURL) xmlPing.WriteEndElement() xmlPing.WriteEndElement() xmlPing.WriteEndElement() xmlPing.Close() Dim technoratiPingResponse As HttpWebResponse = CType(technoratiPing.GetResponse, HttpWebResponse) Dim streamPingResponse As StreamReader = New StreamReader(technoratiPingResponse.GetResponseStream) Dim strResult As String = streamPingResponse.ReadToEnd streamPingResponse.Close() technoratiPingResponse.Close() Catch ex As Exception 'Add code here to flag a service as broken End Try Next End Sub Make sure to set the blogURL and blogName variables to your blog information. With a little more code you could create a page to manage sites to ping. My idea for this page would be:
- Store the sites-to-ping in the database
- The table would have the fields SiteName, Active, and Failed
- In the Try Catch you could flag a site as failed if it fails. Set the Failed to false if it succeeds.
- On the Ping Site Management page display all the sites in a grid. Allow for add, editing, deleting.
I think you have the general idea. |
jeremy at 5:17 PM |
(16) Comments |
Add a comment |
Permalink
|
|
|
Wednesday, August 02, 2006 |
I had the opportunity at the beginning of this year to try out the r.a.d.Grid from Telerik. My partners and I were working on a web application for a client and we were having performance issues with the WebGrid from Infragistics. Now don’t get me wrong here, the WebGrid is a powerful grid. It was just a little too heavy client-side for what we wanted. So mid project we downloaded a trial of the Telerik r.a.d.Grid and gave it a try. We knew immediately it was what we were looking for.
We were able to tailor the features and functionality to get it just the way we wanted it. The performance was great and we were able to set a property, EnableAjax=”True”, and the whole grid used server Callbacks to add, edit, delete, and page. We found the r.a.d.Grid to be very nice indeed. In addition, the grid came with many different skins that could be applied to it with just a property on the grid. This is very important for those of us that take pride in the way forms look, not just the way they function.
Since then, I have implemented almost half of the huge suite of controls that Telerik offers. Other controls that are particularly cool are the r.a.d.Editor (web-based WYSIWYG editor), the r.a.d.Window control, and the AJAX Panel. The AJAX Panel control is just like an ASP.NET Panel control except that anything you stick inside it automatically uses callbacks to the server instead of postbacks. Very cool control.
If you’re a web developer and you’re not using Telerik controls already, you need to check them out. Don’t forget to take a look at their customer list and the forums. |
Jeremy at 8:54 AM |
(4) Comments |
Add a comment |
Permalink
|
|
|
Tuesday, July 25, 2006 |
The fascinating thing about newborn babies is that, much like programming, they require constant troubleshooting. Of course when programming, there are far more possible causes of the error your receiving. The baby's cry being the error you're receiving, only happens for a very limited number of reasons. The following is my programming example of troubleshooting the cry.
Dim objBaby as BabyCLS = YourBaby
If (objBaby.Crying = True) Then If (objBaby.Fed = False) Then objBaby.Stomach.Fill(objFood) Else If (objBaby.DirtyDiaper = True) Then objBaby.DirtyDiaperChange = newDiaper objBaby.DirtyDiaper = False Else If (objBaby.Sleepy = True) Then objBaby.Sleep = True Else 'Start searching google End If End If End If End If |
jeremy at 12:31 PM |
(8) Comments |
Add a comment |
Permalink
|
|
|
Wednesday, March 22, 2006 |
| Invalid Theme or Stylesheet Theme Value |
|
I encountered an issue earlier this week that appears to be a bug in the ASP.NET 2.0 design regarding Themes and Authorization.
I am currently working on a web application for a client that needs to have role based access to specific forms and areas of the application. The whole application needs to be behind a login to begin with. I went ahead and added membership to my database and set up the web.config. I started off by adding the following lines in the web.config located in the root of my application.
<authentication mode="Forms"> <forms loginUrl="Login.aspx" protection="Validation" timeout="30"/> </authentication>
<authorization> <deny users="?"/> <allow users="*"/> </authorization>
I hit run, and like I expected I was presented with a login page instead of the default.aspx. Easy enough, so I started messing with the css and theme for my application. At some point I hit shift+refresh on the browser because a change I made wasn't showing up. All of the sudden, there is no css or theme being applied to my login page. When I switched back to the html view the attribute Theme="MyTheme" was underlined with the error Invalid Theme or Stylesheet Theme Value.
I googled on the exact error and came up with two hits. That's when you think, "Oh crap". I spent the next 4-5 hours playing with old version of my code and trying to figure out where this error had come from and why it was only affecting my login screen. The short answer is that when I denied access to my whole application, to unauthenticated users, the login page is the only page that can be displayed. What I believe to be a bug is that access to theme files that the Login page is using is also denied. I fixed the issue by setting the authorization checks on specific folders and files.
More specifically, if you have the following line in your web.config: <pages styleSheetTheme="Nameofyourtheme"> then you will need the following code if you are using the theme on your login page and your whole site is behind the login page.
<location path="App_Themes"> <system.web> <authorization> <allow users="*"/> </authorization> </system.web> </location>
Since there were only a couple of other hits returned from Google that did not help at all, I hope someone finds this helpful in the future.
Update: Here is a very good thread regarding this issue. http://forums.asp.net/thread/1380242.aspx |
admin at 10:36 PM |
(36) Comments |
Add a comment |
Permalink
|
|
|
|