Can you share these more complete versions, or do we really have to wait for you to wrie an article?
zlezj
Posts
-
Parallelizing code the easy (er) way -
Update silverlight xap fileOK, here's an extended version. This code appends the file date/time to the XAP file name. This way you'll keep the caching of already loaded XAP files and you don't have to remember to change the number...
<%@ Page Language="C#" AutoEventWireup="true" %>
<script runat="server">
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);const string XAP = "ClientBin/XapFile.xap"; System.IO.FileInfo fi = new System.IO.FileInfo(Request.MapPath("./" + XAP)); string timeStampXAP = fi.LastWriteTime.ToString("yyyyMMdd\_HHmmss"); source.Text = String.Format("<param name=\\"source\\" value=\\"{0}?{1}\\" />", XAP, timeStampXAP); }
</script>
<%@ OutputCache Duration="1" VaryByParam="None" Location="None" %>
<!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>Test</title>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
body {
padding: 0;
margin: 0;
}
form {
height: 100%;
}
#host {
height: 100%;
text-align:center;
}
</style>
<script type="text/javascript" src="Silverlight.js"></script>
<script type="text/javascript">
window.onload = function()
{
document.getElementById('host').focus();
}function onSilverlightError(sender, args) { var appSource = ""; if (sender != null && sender != 0) { appSource = sender.getHost().Source; } var errorType = args.ErrorType; var iErrorCode = args.ErrorCode; if (errorType == "ImageError" || errorType == "MediaError") { return; } var errMsg = "Unhandled Error in Silverlight Application " + appSource + "\\n"; errMsg += "Code: " + iErrorCode + " \\n"; errMsg += "Category: " + errorType + " \\n"; errMsg += "Message: " + args.ErrorMessage + " \\n"; if (errorType == "ParserError") { errMsg += "File: " + args.xamlFile + " \\n"; errMsg += "Line: " + args.lineNumber + " \\n"; errMsg += "Position: " + args.charPosition + " \\n"; }
-
Update silverlight xap fileThe old XAP file probably lingers on somewhere in a cache. You could try to rename the XAP file, or add a random number in the source parameter of the object tag like
<param name="source" value="XapFile.xap?12345"/>
-
Try to find something dumber if you can...Do you mean the SQL injection vulnerability, the fact that data is stored in the session object or that you don't like this kind of validation?
-
I don't want to know the code behind this...From the Visual SourceSafe documentation[^]: Visual SourceSafe defines a label as a string of up to 31 characters. Any of the following is a valid label: "1.0", "2.01b", "Final Beta", and "Approved for QA". Label names cannot start with a capital "L" or "#s". At least it's documented...
-
Beware of macros!Thatswhy I always use braces when using if/while/for statements. On the other hand: all multi-line macros could be defined inside a
do { ... } while (0)
block. This prevents problems like the one mentioned and works correctly with semicolons -
Retrieve the PK after an add into an in memory DataTableNot possible.
-
Debugging SQLYep, that was causing the problems
-
Debugging SQLI usually don't use the like operator and I always trim my strings before storing them in a database, so I never ran into this. If this scenario was in a developers-quiz, I wonder: how many developers would answers this question correct?
-
Debugging SQLI found this subtlety while debugging some SQL Server code. The first SELECT statement yields 2 rows, the second only 1, the third 2. Frankly: I expected the first two resultsets to be the same...
CREATE TABLE test (
value NVARCHAR(10)
)
GOINSERT INTO test(value) VALUES('0000001');
INSERT INTO test(value) VALUES('0000001 ');
GOSELECT * FROM test WHERE value='0000001'
SELECT * FROM test WHERE value LIKE '%1'
SELECT * FROM test WHERE value LIKE '%1%'
GODROP TABLE test
GO -
Silverlight & WindowsUse WPF
-
I have no name, I don't existThere was, but it has been renamed to Wicked Code. See http://www.codeproject.com/Feature/WickedCode.aspx?msg=3041439#xx3041439xx[^]
-
I have no name, I don't existWhy do you classify this as a coding horror? I would say this is more like a subtle bug...
-
Who is teaching these people?It's a pity that this scheme for line-numbering does not work
-
Dynamically ENUM -
Code reuseI guess the programmer of the snippet below found a function to fill a DropDownList and adjusted it just enough to fill a TextBox...
Private Sub ShowName(ByVal id As String)
Dim daNames As New SqlDataAdapter("SELECT ID, NAME FROM TBL\_NAMES", ConnectionString) Dim dsNames As New DataSet("NAMES") daNames.Fill(dsNames, "NAMES") Dim drNames As DataRow = dsNames.Tables(0).NewRow drNames("ID") = -1 drNames("NAME") = "" dsNames.Tables(0).Rows.InsertAt(drNames, 0) If dsNames.Tables("NAMES").Rows.Count > 0 Then Try Dim drs() As DataRow = dsNames.Tables(0).Select("ID = " & id) txtName.Text = drs(0).Item("NAME").ToString Catch e As Exception ' End Try Else txtName.Text = "" End If
End Sub
-
There are errors and errors...From one of the articles on this very website a description of a function named Open: Opens an existing WAV file. Returns a String, which will be blank upon success, and upon error, will contain the reason it failed. This method will throw an exception for a more serious error.