Thursday, October 30, 2008
_PendingCallbacks[...].async is null or not an object BUG
_PendingCallbacks[...].async is null or not an object error can be related to a bug in the javascript that VS creates for you to deal with callbacks. You can alleviate PendingCallback errors by checking all of your own javascript for any variables named i. Replace them and you should be golden.
Friday, October 3, 2008
Show and hide a panel with javascript
* Make note of the Z-INDEX on the row. This will allow the visible panel to appear above other items on the page.
In the HTML
<tr style="Z-INDEX: 10; POSITION: absolute">
<td>
<asp:Panel Runat="server" ID="ThePanel" BorderWidth="1px" BorderStyle=Solid>
<asp:Literal Runat="server" ID="TheResults"></asp:Literal>
</asp:Panel>
</td>
</tr>
In the js file
function ShowPanel(target)
{
if (target != null)
{
target.style.display = '';
}
}
function HidePanel(target)
{
if (target != null)
{
target.style.display = 'none';
}
}
In the code behind
protected override void OnPreRender(EventArgs e)
{
this.TheLabel.Attributes.Add("onmouseover", "ShowPanel("+this.ThePanel.ID+");");
this.TheLabel.Attributes.Add("onmouseout", "HidePanel("+this.ThePanel.ID+");");
this.ThePanel.Style.Add("display", "none");
base.OnPreRender (e);
}
In the HTML
<tr style="Z-INDEX: 10; POSITION: absolute">
<td>
<asp:Panel Runat="server" ID="ThePanel" BorderWidth="1px" BorderStyle=Solid>
<asp:Literal Runat="server" ID="TheResults"></asp:Literal>
</asp:Panel>
</td>
</tr>
In the js file
function ShowPanel(target)
{
if (target != null)
{
target.style.display = '';
}
}
function HidePanel(target)
{
if (target != null)
{
target.style.display = 'none';
}
}
In the code behind
protected override void OnPreRender(EventArgs e)
{
this.TheLabel.Attributes.Add("onmouseover", "ShowPanel("+this.ThePanel.ID+");");
this.TheLabel.Attributes.Add("onmouseout", "HidePanel("+this.ThePanel.ID+");");
this.ThePanel.Style.Add("display", "none");
base.OnPreRender (e);
}
Thursday, September 25, 2008
DataSet / DataTable Primary Key and using DataRow.Find
It's quick and easy to find items in a DataTable through setting the primary key. This method can be used to easily populate a CheckBoxList
DataSet ds = //populate dataset
if(ds != null && ds.Tables.Count > 0)
{
GroupCBL.DataSource = ds;
GroupCBL.DataTextField="textField";
GroupCBL.DataBind();
DataColumn[] dc = new DataColumn[1];
dc[0] = ds.Tables[0].Columns["key"];
ds.Tables[0].PrimaryKey = dc;
foreach(ListItem item in GroupCBL.Items)
{
DataRow row = ds.Tables[0].Rows.Find(item.Value);
item.Selected = Convert.ToBoolean(row["selected"]);
}
}
DataSet ds = //populate dataset
if(ds != null && ds.Tables.Count > 0)
{
GroupCBL.DataSource = ds;
GroupCBL.DataTextField="textField";
GroupCBL.DataBind();
DataColumn[] dc = new DataColumn[1];
dc[0] = ds.Tables[0].Columns["key"];
ds.Tables[0].PrimaryKey = dc;
foreach(ListItem item in GroupCBL.Items)
{
DataRow row = ds.Tables[0].Rows.Find(item.Value);
item.Selected = Convert.ToBoolean(row["selected"]);
}
}
Friday, September 12, 2008
Restart a remote machine.
Having problems with the remote machine you are using? Don't want to leave home to head to the office for a restart? Simple cmd can take care of it.
C:\Documents and Settings\unplug1.6>shutdown -m \\Hum -r -y
shutdown is the command you're looking for, "-r" is to specify a restart instead of total shutdown. "-m \\Hum" specifies the remote computer you are trying to restart. Below are a few other arguments.
Usage:
shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
C:\Documents and Settings\unplug1.6>shutdown -m \\Hum -r -y
shutdown is the command you're looking for, "-r" is to specify a restart instead of total shutdown. "-m \\Hum" specifies the remote computer you are trying to restart. Below are a few other arguments.
No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c "comment" Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
Usage:
shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]
Monday, September 8, 2008
Refreshing the project failed. Unable to retrieve folder information from the server.
I've been working with Visual Studios 2003 and have had the error "Refreshing the project failed. Unable to retrieve folder information from the server." pop up as I'm loading the project. I normally ignore it and go about my business. I finally tired of seeing the pop up and hit the interweb for answers.
To correct the problem simply delete the "VSWebCache" from the "\Documents and Settings\[Username]" directory.
Tuesday, July 8, 2008
Delete the result of an inner join from a SQL table
If you want to delete the result of an inner join from a table, you just need to be redundant...
delete
from userregionlocation
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
Whatever the result set of:
is what will be deleted from the "userregionlocation" table.
delete
from userregionlocation
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
Whatever the result set of:
select *
from userregionlocation t
inner join @res r on r.userid=t.userid and r.region=t.region and r.location=t.location
is what will be deleted from the "userregionlocation" table.
Monday, June 30, 2008
Retrieving a file that is stored in a database as an image.
1. Create a "File Server" as an HttpHandler
-Within the web.config, set up a page (filemanager.aspx below) that will handle http requests.
<system.web>
<httpHandlers>
<add verb="*" path="filemanager.aspx" type="Project.FileManagerHttpHandler, DLLName"/>
</httpHandlers>
</system.web>
2. Within the html page, create a hyperlink to the http handler
http post to server: <a href="http://url/fileserver.aspx?uniqueIdentifier">click here</a>
3. Create the class that will handle the http request
public class FileServerHttpHandler : IHttpHandler, IRequiresSessionState
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
try
{
Guid token = new Guid(context.Request.QueryString.ToString());
BinaryWriter bw;
context.Response.Clear();
using (SqlDataReader dr = SqlHelper.ExecuteReader(DBHelper.ConnectionString, "FileGetByFileToken", token))
{
if (dr != null)
{
if (dr.Read())
{
context.Response.ContentType = dr["filetype"].ToString();
byte[] o = (byte[]) dr["filedata"];
bw = new BinaryWriter(context.Response.OutputStream);
bw.Write(o);
}
dr.Close();
}
}
}
catch (Exception)
{
}
}
// Override the IsReusable property.
public bool IsReusable
{
get { return true; }
}
-Within the web.config, set up a page (filemanager.aspx below) that will handle http requests.
<system.web>
<httpHandlers>
<add verb="*" path="filemanager.aspx" type="Project.FileManagerHttpHandler, DLLName"/>
</httpHandlers>
</system.web>
2. Within the html page, create a hyperlink to the http handler
http post to server: <a href="http://url/fileserver.aspx?uniqueIdentifier">click here</a>
3. Create the class that will handle the http request
public class FileServerHttpHandler : IHttpHandler, IRequiresSessionState
{
// Override the ProcessRequest method.
public void ProcessRequest(HttpContext context)
{
try
{
Guid token = new Guid(context.Request.QueryString.ToString());
BinaryWriter bw;
context.Response.Clear();
using (SqlDataReader dr = SqlHelper.ExecuteReader(DBHelper.ConnectionString, "FileGetByFileToken", token))
{
if (dr != null)
{
if (dr.Read())
{
context.Response.ContentType = dr["filetype"].ToString();
byte[] o = (byte[]) dr["filedata"];
bw = new BinaryWriter(context.Response.OutputStream);
bw.Write(o);
}
dr.Close();
}
}
}
catch (Exception)
{
}
}
// Override the IsReusable property.
public bool IsReusable
{
get { return true; }
}
Subscribe to:
Posts (Atom)