Month: July 2008
ASP.NET Debugging Stop Unexpectedly
Page.ResolveUrl(“~/ClientScripts/Validation.js”) – Web Application Root Operator
ASP.NET AJAX WebServices and ScriptServices
AJAX and JavaScript in ASP.NET & Visual Studio 2008
When Leaving Page, Prompt The User That Changes Have Not Been Saved
[sourcecode language=”xml”]
body onunload=”ConfirmExit”
[/sourcecode]
[sourcecode language=”javascript”]
OnClientClick=”isDirty=false”
[/sourcecode]
[sourcecode language=”csharp”]
public partial class TestPromptSave : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack == false) {
SetupJSdataChange(form1);
}
}
private void SetupJSdataChange(Control parentControl) {
foreach (Control control in parentControl.Controls) {
//Response.Write(control.ID + “<br>”);
if (control is WebControl) {
WebControl webControl = control as WebControl;
webControl.Attributes.Add(“onchange”, “InputChanged(this)”);
}
}
}
protected void Page_Save(object sender, EventArgs e) {
}
}
[/sourcecode]
HEre some more
[sourcecode language=”xml”]
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”TestPromptSave.aspx.cs” Inherits=”TestPromptSave” %>
<!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 >
<script type=”text/javascript” language=”javascript”>
var isDirty = false;
window.onbeforeunload = ConfirmExit;
function InputChanged(control)
{
isDirty = true;
}
function ConfirmExit()
{
if(isDirty == true){
return “You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?”;
}
}
</script>
<form id=”form1? runat=”server” >
<a href=”RedirectPage.aspx”>RedirectPage.aspx</a>
<br /><br />
<table>
<tr>
<td>
First Name
</td>
<td>
<asp:TextBox ID=”txtFirstname” runat=”server” />
</td>
</tr>
<tr>
<td>
Last Name
</td>
<td>
<asp:TextBox ID=”txtLastName” runat=”server” />
</td>
</tr>
<tr>
<td>
State
</td>
<td>
<asp:DropDownList ID=”ddlState” runat=”server” >
<asp:ListItem Text=”" Value=”" />
<asp:ListItem Text=”CO” Value=”CO” />
<asp:ListItem Text=”TX” Value=”TX” />
<asp:ListItem Text=”FL” Value=”FL” />
<asp:ListItem Text=”OK” Value=”OK” />
</asp:DropDownList>
</td>
</tr>
</table>
<br />
<asp:Button ID=”butSave” runat=”server” Text=”Save” OnClientClick=”isDirty=false” onclick=”Page_Save” /> |
<asp:Button ID=”butCancel” runat=”server” Text=”Cancel” />
</form>
</body>
</html>
[/sourcecode]
http://www.4guysfromrolla.com/webtech/100604-1.shtml
SQL Server Searching Object Text
SELECT OBJECT_NAME(id), *
FROM syscomments
WHERE
(
OBJECTPROPERTY(id, ‘IsScalarFunction’) = 1
OR OBJECTPROPERTY(id, ‘IsTableFunction’) = 1
OR OBJECTPROPERTY(id, ‘IsProcedure’) = 1
OR OBJECTPROPERTY(id, ‘IsView’) = 1
)
AND [Text] NOT LIKE ‘%IsDeleted%’
Name, *
sys.objects
WHERE
(
OBJECTPROPERTY(object_id, ‘IsScalarFunction’) = 1
OR OBJECTPROPERTY(object_id, ‘IsTableFunction’) = 1
OR OBJECTPROPERTY(object_id, ‘IsProcedure’) = 1
OR OBJECTPROPERTY(object_id, ‘IsView’) = 1
)
AND OBJECT_DEFINITION(object_id) NOT LIKE ‘%IsDeleted%’
Searching Syscomments Accurately (View the Comments section)
SQL Server Custom Shortcuts
SQL Server For Each Procedure
PROCEDURE sp_ForEachProcedure
VARCHAR(MAX),
VARCHAR(MAX) = NULL,
BIT = 1,
BIT = 0
@executeCommand NVARCHAR(MAX)
@executeCommand =
+
+
+
+
+ REPLACE(@command1, ””, ”””) + ”’, ”?”, ”[” + p.name + ”]”)’ + ‘ AS Statement’ +
(@whereand IS NOT NULL)
SET @executeCommand = @executeCommand +
+ REPLACE(@whereand, ”, ””)
(@print = 1)
SET @executeCommand = @executeCommand + ‘ SELECT * FROM @statementTable’
@execute = 1
SET @executeCommand = @executeCommand +
‘ DECLARE @loopCount INT ‘ +
‘ DECLARE @statement NVARCHAR(MAX) ‘ +
‘ SELECT @loopCount = COUNT(*)FROM @statementTable ‘ +
‘ WHILE @loopCount <> 0 ‘ +
‘ BEGIN ‘ +
‘ SET @statement = (SELECT statement FROM @statementTable WHERE ID = @loopCount) ‘ +
–‘ PRINT ”EXECUTING: ” + @Statement ‘ +
‘ EXEC sp_executesql @Statement ‘ +
‘ SET @loopCount = @loopCount – 1 ‘ +
‘ END ‘
sp_executesql @executeCommand