
travisowens
Avatar/Signature-
Posts
109 -
Joined
-
Last visited
Content Type
Profiles
Forums
Blogs
Events
Articles
Resources
Downloads
Gallery
Everything posted by travisowens
-
Keep in mind, datareader's increase in speed also means it has reduced functionality, but if you don't need certain features you get from a dataset, then no loss. As far as speed, fastest to slowest: 1. ram 2. database server (even if it's running on a separate box) 3. xml file Keep in mind, storing a XML file and reading it into ram is slow that querying the database, because you have to do #3 and then do #1. I once benchmark compared a system I wrote (before .NET) that would read .HTML templates off the harddrive, and when I put the HTML text inside a database table, I could read the database 8x faster than a .HTML file off the HD. Of course 8x faster than microscopic is still microscopic, I didn't use the "template in a database" code because it was seriously more complex to alter a template inside a column vs simply editing a .HTML file on the drive. It would only be an acceptable trade-off when you're dealing with millions of hits (Amazon, eBay). As a beginner, don't always go the fastest route, keep things good and flexible, don't forget the KISS rule. Also, if you read into Yahoo's research, only 5% of the total time it takes a webpage to draw is spent on your server code, the other 95% is spent on parsing your HTML/JS/CSS so spend your time outputting great HTML if you want speed improvements. Explaining that is far beyond the scope of this thread.
-
The following syntax is legit but it then the button no longer goes anywhere. <button><a href="?action=go">GO</a></button>
-
I have a page where I have <button> tags and I simply wrap them inside <a href> but TIDY says this is not legit. What's the correct way to do the following: <a href="?action=go"><button>GO</button></a> The W3C doesn't mention anything either: http://www.w3schools.com/tags/tag_button.asp Technically, the traditional way to do this, which works fine but is very verbose is: <form style="display: inline;"><input type="hidden" name="action" value="go"><input type="submit"></form> but as you have more GET values to push, this gets very long (I already have 3 in my real code). I'm just looking for a cleaner & more elegant way to achieve this.
-
You need to use a WinForm as otherwise you'd have to write a custom ActiveX app to do the file management, which IE7 will pretty much push the user not to install. Also, since you want this to run at logon time ("authenticate a User during logon") then you'll also want it a WinForm as you can put the .EXE in their startup, which will be much neater than trying to push a web url to the user, which can not function correctly if the user changes their default browser.
-
IN a dynamically (via SQL) generated survey I need to enforce a minimum on some checkbox questions. So let's say I have 10 colors and you need to "pick at least 2". Let's assume I have 3 of these questions in my survey. Ideally, I would like the submit button onclick fire off an alert to tell the user that questions 1, 2, 3 need addressing if they don't have the minimum. I already have a CSS class that toggles to give a visual cue that the question isn't valid, but now I need to actually enforce it. (PS: server side isn't important now) The only way I can think of doing this is to create a 3x4 array that contains (question#, checkbox name, number of checkboxes, min) .... which would look like (1, 'chkColor_', 10, 2). The function would take each row of the array, loop thourgh all the IDs (via 'chkColor' + for 0 to 9) and if the min isn't met, fire an alert that says "question "+ question + " requires at least "+ min +" choices." Is there a more efficient way to do this then sending a 3x4 array?
-
RESOLVED It seems VS2005 does have decent RegEx support, but it uses it's own syntax. Silly me for not clicking the arrow next to the textbox to see it. You can also read up about it at: http://www.codinghorror.com/blog/archives/000633.html
-
I wouldn't have questioned this at all if I had seen a more formal syntax, such as if(x) { with(x) { style.setExpression('left',document.body.clientWidth-60) } } I'm outright shocked that with() works outside the brackets.
-
. ...........RESOLVED (see next post) . I'm looking into somebody's Javascript code and I came across this syntax, I have no idea what the if/with line means and Google isn't helping. BTW, this is part of a web control that puts a HELP link on the top right of pages. <div id="HelpTopRight" class="HelpTopRight" style="white-space:nowrap;"> <xsp:HelpLink ID="lnk" runat="server" /> </div> <script type="text/javascript" language="javascript"> var x=document.getElementById('HelpTopRight') [b]if(x)with(x)[/b] { style.setExpression('left',document.body.clientWidth-60) } </script>
-
Call me a nit picker but I would assign "head" to a variable outside the look and reference to it, preferably at the beginning of your method. I hate to absolutely hardcode something like that inside a loop, especially when the loop is much larger, you never know when you'll need to change it and imho defining the target string is best put at the top of the method.
-
Too bad the RegularExpression objects don't have their own Split, you could probably write a pretty flexible split based on regex.
-
I don't think you're going to be truly happy with scaling unless you use WPF (Windows Presentation Foundation) which is a Vista only thing (and soon to be XP too) and will require VS2005 or VS2007. Otherwise, just anchor your controls properly and deal with the minor consequences.
-
PS: ignore all quotes, just there to wrap up the regex, also this forum trims spaces so I've said 4 spaces instead of typing them. Does VS2005's search & replace lack full RegEx support (ala .Net's)? I'm trying to safely convert the 4 space indents to tabs, and want to do this safely. Meaning I don't want to simply convert "4 spaces" to "\t" just in case some string or other (non indenting) spacing exists. I tried the following RegExs and VS2005 didn't like them, what am I doing wrong? ^( ){1,} ^(\s{4}){1,}Anybody reading this should read those as 4 spaces, in sets of 1 or more that start at the beginning of the line. The only thing I can get to work in VS2005 is "^4 spaces". I cannot do sets or use \s, what gives?!
-
Resolved... I simply needed to use RepeatDirection="Horizontal" I have a RadioButtonList and even when I do RepeatLayout="Flow" it's output <br> tags that I can't override with Display: inline; <asp:RadioButtonList ID="DistanceBW" runat="server" CssClass="RadioGrid" RepeatLayout="Flow"> <asp:ListItem Value="20ft" Text="" /> <asp:ListItem Value="21ft to 40ft" Text="" /> <asp:ListItem Value="41ft to 60ft" Text="" /> </asp:RadioButtonList> which outputs <span id="ctl00_Content_DistanceBW" class="RadioGrid"> <input id="ctl00_Content_DistanceBW_0" type="radio" name="ctl00$Content$DistanceBW" value="20ft" /><br /> <input id="ctl00_Content_DistanceBW_1" type="radio" name="ctl00$Content$DistanceBW" value="21ft to 40ft" /><br /> <input id="ctl00_Content_DistanceBW_2" type="radio" name="ctl00$Content$DistanceBW" value="41ft to 60ft" /> </span> How can I get these radio buttons to align side by side?
-
How to stop RadioButtonList creating a <table>
travisowens replied to travisowens's topic in ASP.NET
Looks like I should have googled harder before posting... All I had to do was add RepeatLayout="Flow" to the <asp:RadioButtonList tag -
RESOLVED... see the following post I have the following markup <asp:RadioButtonList ID="DistanceBW" runat="server" CssClass="RadioGrid"> <asp:ListItem Value="20ft" Text="" /> <asp:ListItem Value="21ft to 40ft" Text="" /> <asp:ListItem Value="41ft to 60ft" Text="" /> <asp:ListItem Value="61ft to 99ft" Text="" /> <asp:ListItem Value="100ft" Text="" /> <asp:ListItem Value="NA" Text="" /> </asp:RadioButtonList> which outputs <table id="ctl00_Content_ImageDistance" class="RadioGrid" border="0"> <tr> <td><input id="ctl00_Content_ImageDistance_0" type="radio" name="ctl00$Content$ImageDistance" value="20ft" /></td> </tr><tr> <td><input id="ctl00_Content_ImageDistance_1" type="radio" name="ctl00$Content$ImageDistance" value="21ft to 40ft" /></td> </tr><tr> <td><input id="ctl00_Content_ImageDistance_2" type="radio" name="ctl00$Content$ImageDistance" value="41ft to 60ft" /></td> </tr><tr> <td><input id="ctl00_Content_ImageDistance_3" type="radio" name="ctl00$Content$ImageDistance" value="61ft to 99ft" /></td> </tr><tr> <td><input id="ctl00_Content_ImageDistance_4" type="radio" name="ctl00$Content$ImageDistance" value="100ft" /></td> </tr><tr> <td><input id="ctl00_Content_ImageDistance_5" type="radio" name="ctl00$Content$ImageDistance" value="NA" /></td> </tr> </table> I want all these checkboxes next to each other (it's going to be part of a table, made up in CSS) but how can I prevent ASP.Net from putting these in seperate <tr>'s?
-
I have no idea what was wrong with the code, but I recreated my method from scratch and it worked, here's the code... public int GetFileCount(string sFolder, string sExtension) { return System.IO.Directory.GetFiles( sFolder , sExtension , SearchOption.AllDirectories ).Length; } The reason I'm executing this is to set a Max value on a progress bar (as each file I analyze later in the code increments the progress bar by 1). When I originally used a recursive function it took about 3 secs just to calculate the total count, but using this much slicker solution it happens near instantly. So if you plan on doing something with the filters (ex: reading their contents, checking file meta data, etc) you want recursion, but if you merely want a file count, this is way more efficient.
-
Counting all the files in a directory tree (resolved) THIS PROBLEM IS RESOLVED I simply want to count all the files (of a certain file extension) in a folder & all of it's subfolders. I came across this code on another forum but it only returns 0. return System.IO.Directory.GetFiles( sFolder , sExtension ).Length; So I changed changed it as it seems the poster forgot one of the requirements was to support subfolders so I changed it like so: return System.IO.Directory.GetFiles( sFolder , sExtension , SearchOption.AllDirectories ).Length; Any ideas? Even when the extension is "*.*" it fails, and this folder tree has 14,000+ files, some in the root folder and tons in many sub folders.
-
No biggie, I do it too, for awhile I was working on a classic ASP app and when I went back to my C# code, I forgot all my ;s and didn't notice until the build didn't work.
-
Thanks! I wasn't even thinking, my brain is in WinForms mode, I don't know why I had forgotten about using a session. PS: in any kind of collection/array in C# it's [] not ()
-
Why won't this int keep incrementing? I just created a simple web page in VS2005 and dropped a button and a label. I simply want the label to increment every time the button is pushed, which works fine the first click, but after that Count is always 1. What simple thing am I not seeing? public partial class _Default : System.Web.UI.Page { public int _count = new int(); public void Page_Load(object sender, EventArgs e) { } public void btnIncrement_Click(object sender, EventArgs e) { Count = Count + 1; lblCount.Text = Count.ToString(); } public int Count { get { return _count; } set { _count = value; } } } and if you want to see the generated HTML <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="btnIncrement" runat="server" OnClick="btnIncrement_Click" Text="Increment" /><br /> <asp:Label ID="lblCount" runat="server" Text="0"></asp:Label></div> </form> </body> </html>
-
I find it best to write code from top to bottom, instead of the way most coders do, which is bottom to top. This means instead of writing functional code as step 1, step 2, etc I design my application via a series of empty verbose & well commented methods. Say I'm writing a program for users on a network. At first I design a UI in the designer to think about how a program works, plus it gives you something quick to show people. After I feel the UI is well designed and possibly set in stone, I jump to the code and the first kind of stuff I write would be... PopulateFormWithDefaults(); I create that method and it would contain something like... GetAppSettings(); PopulateUsername(); PopulateState(); ... I then create empty methods for all of these. Keep in mind I write an XML comment for each method that explains what it does. Admit to yourself that if you don't write comments as you write code (even an empty method is code) then you never will get around to it. I usually keep going on with this until I get to the smallest parts of my app, often as small as trivial methods like IsNumeric() or whatever. From there I begin coding whatever method grabs my attention first but usually I code it with the top-most methods. This way my application begins to have some functionality initially, all the time commenting every line of code (I'm a firm believer that if every line of code was removed, my app could be totally rewritten as is from comments alone). By creating apps this way, you begin to look at your app from a functionality standpoint, which I feel is very OOP like. It helps prevent you from writing long chunks of code as every aspect of the app is broken into it's own method. I find this format as a good way at preventing sloppy code. I learned this method from a professional programmer who now works at Microsoft. Considering he's been coder much longer than myself, and the companies he has worked for, and now works at, tells me it's a very good methodology.
-
Anybody who's writing a RegEx (regular expression) knows that they can be hard to troubleshoot & debug. Or more importantly, trying to learn them can be equally as hard because there is no easy way to test out your regex. Because of this, I decided to write a quick & simple .Net 2.0 app that lets you enter a regex and a string to match against, and it displays in realtime if the regex is a match, not a match, or invalid regex. I've also included the source code, and I welcome anybody to make improvements and email the source back to me. Also, I've included some regexes I wrote that I like to call my "Ultimate Regexes" because they are very flexible and cover every sane alternate way to enter such data. The regexes I've included are US Phone, International Email, US Zip Code, US Social Security number and Credit Card number. http://rhelik.lehost.net/blog/RegEx.gif Get the Ulitily (10k zipped .EXE) Get the Source Code (103k zip)
-
I've been having a hard time finding reviews (Amazon doesn't even seem to sell the package) about NetAdvantage 2005. I fully understand they're considered the best on the market for 3rd party controls and I have used 2004 in the past but I wanted some opinions on the 2005 package, especially when it comes to their ASP.Net controls and if anybody finds them slow at all. The closest thing I've come across as a review was here but virtually all of them were for 2004 http://www.componentsource.com/catalog.asp?sc=EACTL&option=15777&fl=&RC=TSUMP&bc=&PO=512326&ul=en&vw=T17
-
We have a database setup that runs on a high availability server all on the SAN, the database server IS NOT on the webserver. Our goal is to get our webapps into a more fault tolerant enviroment. I am aware that trying to NLB and Sync a database requires an expert, it's very dangerous & messy work. Personally I think manually sync'ing files on 2 or more webservers is a bad idea as you should never underestimate human error. The File Replication Services are pretty reliable and there's no reason you can't sync the two websites without affecting server load. Actually I did some howemork and found a really good review of Network Load Balancing called "Web Farming with the Network Load Balancing Service in Windows Server 2003" by Rick Strahl found at http://www.west-wind.com/presentations/loadbalancing/NetworkLoadBalancingWindows2003.asp where the guy pulled the plug to see what happens and it's very interesting. Also he reminds us that NLB runs on the network level and not the app level, so if your server is up but your webserver is dead, it will still attemp to server web requests and fail ungraciously. Because of this, we are going to rethink our plan and decide if you can live with this scenario or if we truly need 100% uptime which will require a 3rd party solution that can be app (port) aware. I should also point out that IIS6 is EXTREMELY fault tolerant and each webapp runs seperately with auto restarting so the worst case scenario is a webapp crashes and restarts itself (all within a couple seconds) and does not affect any other web app. So the fact that NLB can't monitor apps isn't much to get worried about as long as you're on 2003 & IIS6.
-
<sarcasm> You'd be amazed at what you'll find at this one cool site, it's called Google.com "Microsoft Speech Recognition C#" or "Microsoft Speech Recognition tutorial" etc. </sarcasm>