|
Are you able to manually (i.e. thru the Windows UI) create a file with the same path name? That would help identify if it's a permissions issue.
/ravi
|
|
|
|
|
Just for grins, does this work any better?
WebClient wc = new WebClient();
wc.DownloadFile ("http://.../foo.jpg", @"C:\MyFolder\foo.jpg");
You may want to save the image to your user's application data path (to which you have write access).
/ravi
|
|
|
|
|
Hi Ravi,
thanks for the reply,
i tried downloading the file to the users application data but still get the error.
living life on the flip side
|
|
|
|
|
Is is possible that the target file has already been opened (for exclusive read or write), thereby preventing it from being overwritten? Although I think if that were the case you'd see a different exception.
/ravi
|
|
|
|
|
Agweet wrote: i am not an idiot, and that was not truly called for
I'm sorry - did I call you an idiot? If you look at the threads, I was talking to Luc, and making a generic comment about technical support phone calls. Trust me, if I wanted to insult you, you would know all about it!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
OriginalGriff wrote: You've clearly not handled technical support calls from non-technical users!
I seem to find ways that ensure they don't come back...
|
|
|
|
|
Please oh great one! Tell me your secrets!
[edit]"oh", you clumsy typist Griff, "oh" - not "of"[/edit]
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Sorry, I have no solution for you. Just a question: Why don't you use WebClient.DownloadFile for downloading the image?
Anyway, your code seems to be correct...
P.S. Have you heard about Path.Combine (because
+"\\" doesn't look so good)
|
|
|
|
|
Hi,
i have gridview and have Detail View.
I want to edit the page with all controls loaded instead of showing in Bound Field.
While using <asp:CommandField ShowEditButton="True" />
i am able to show all values in Text boxes.
Instead i need to show in respective controls like textbox,checkboxlist,listbox and drop down.How to implement this?
Any urls or links?
Guhananth.S
|
|
|
|
|
Please stop this now. You have become very annoying.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi,
i have gridview and have Detail View.
I want to edit the page with all controls loaded instead of showing in Bound Field.
While using <asp:CommandField ShowEditButton="True" />
i am able to show all values in Text boxes.
Instead i need to show in respective controls like textbox,checkboxlist,listbox and drop down.How to implement this?
Any urls or links?
<pre>
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="MenuList.aspx.cs" Inherits="MenuList" %>
<!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></title>
</head>
<body>
<form id="form1" runat="server">
<table>
<tr>
<td valign="top">
<asp:GridView ID="grd_MenuList" runat="server" AutoGenerateColumns="False"
onrowdatabound="grd_MenuList_RowDataBound" DataKeyNames="MenuId"
onselectedindexchanged="grd_MenuList_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="MenuId" HeaderText="MenuId" Visible="false" />
<asp:BoundField DataField="MenuName" HeaderText="MenuName"
SortExpression="MenuName" />
<asp:hyperlinkfield headertext="URL"
datatextfield="URL"
datanavigateurlfields="URL"
datanavigateurlformatstring="details_title.aspx?titleid={0}" />
<asp:BoundField DataField="Status" HeaderText="Status"
SortExpression="Status" />
<asp:TemplateField HeaderText="Role">
<ItemTemplate >
<asp:Label ID="lbl_Role" runat="server" ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<%-- <asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:HyperLink ID="hyp_Edit" runat="server" NavigateUrl='<%# Bind("MenuId") %>'
Text="Edit"></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>--%>
<%-- <asp:CommandField HeaderText="Edit" ShowCancelButton="False"
ShowEditButton="True" ShowHeader="True" />--%>
<asp:CommandField ShowSelectButton="True" />
<%-- <asp:HyperLinkField HeaderText="Edit Details..." Text="Edit Details..." DataNavigateUrlFields="MenuId"
DataNavigateUrlFormatString="MenuCreation.aspx?ID={0}" /> --%>
</Columns>
</asp:GridView>
</td>
<td valign="top">
<asp:DetailsView AutoGenerateRows="False" DataKeyNames="MenuId" DataSourceID="SqlDataSource3"
HeaderText="Menu Details" ID="dtv_Menu" runat="server" Width="275px"
onitemupdated="dtv_Menu_ItemUpdated">
<Fields>
<asp:BoundField DataField="MenuName" HeaderText="MenuName"
SortExpression="MenuName" />
<asp:BoundField DataField="URL" HeaderText="URL" SortExpression="URL"/>
<asp:CheckBoxField DataField="ParentMenuId" HeaderText="Is Parent" />
<asp:BoundField DataField="ParentMenuId" HeaderText="ParentMenuId"
SortExpression="ParentMenuId" />
<asp:TemplateField>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Order" HeaderText="Order" SortExpression="Order" />
<asp:BoundField DataField="RoleName" HeaderText="RoleName"
SortExpression="RoleName" />
<asp:BoundField DataField="Access" HeaderText="Access" SortExpression="Access" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:BoundField DataField="MenuId" HeaderText="MenuId" Visible="False"
ReadOnly="True" SortExpression="MenuId" />
<asp:CommandField ShowEditButton="True" />
<asp:HyperLinkField HeaderText="Edit Details..." Target="_top" Text="Edit Details..." DataNavigateUrlFields="MenuId"
DataNavigateUrlFormatString="MenuCreation.aspx?ID={0}" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:AZSSA_TestConnectionString %>"
SelectCommand="SELECT Menu.URL, Menu.ParentMenuId, Menu.MenuName, Menu.[Order], Menu.Status, Roles.RoleName, MenuRole.Access, Menu.MenuId FROM MenuRole INNER JOIN
Menu ON MenuRole.MenuId = Menu.MenuId INNER JOIN
Roles ON MenuRole.RoleId = Roles.RoleID
WHERE (Menu.MenuId = @MenuId)" >
<SelectParameters>
<asp:ControlParameter ControlID="grd_MenuList" Name="MenuId" PropertyName="SelectedValue"
Type="Int16"/>
</SelectParameters>
<%-- <UpdateParameters>
<asp:Parameter Name="au_lname" />
<asp:Parameter Name="au_fname" />
<asp:Parameter Name="phone" />
<asp:Parameter Name="address" />
<asp:Parameter Name="city" />
<asp:Parameter Name="state" Type="String" />
<asp:Parameter Name="zip" Type="String" />
<asp:Parameter Name="contract" />
<asp:Parameter Name="au_id" Type="String" />
</UpdateParameters>--%>
</asp:SqlDataSource>
</td>
</tr>
</table>
</pre>
<code>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Examples;
using System.Data;
using System.Data.SqlClient;
using System.Text;
public partial class MenuList : System.Web.UI.Page
{
public string strRoleName="";
protected void Page_Load(object sender, EventArgs e)
{
grd_MenuList.DataSource = SP.GetMenuList();
grd_MenuList.DataBind();
}
protected void grd_MenuList_SelectedIndexChanged(object sender, EventArgs e)
{
dtv_Menu.ChangeMode(DetailsViewMode.ReadOnly);
}
protected void dtv_Menu_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
grd_MenuList.DataBind();
}
</code>
Thanks
S.Guhananth
|
|
|
|
|
You are disregarding the forum guidelines in many ways and your question now is very unlikely to get any answers. Fix it! read the guidelines, and edit your message, do not start yet another one.
|
|
|
|
|
|
You are disregarding the forum guidelines in many ways and your question now is unlikely to get any answers. Fix it!
|
|
|
|
|
This is my code
if (sender is ContextMenuStrip)<br />
{<br />
foreach (ContextMenuStrip item in (((ContextMenuStrip)sender).GetCurrentParent().Items))<br />
{<br />
if (item == sender) item.Checked = true;<br />
if ((item != null) && (item != sender))<br />
{<br />
item.Checked = false;<br />
}<br />
}<br />
}
This is my error
Error 1 'System.Windows.Forms.ContextMenuStrip' does not contain a definition for 'GetCurrentParent' and no extension method 'GetCurrentParent' accepting a first argument of type 'System.Windows.Forms.ContextMenuStrip' could be found (are you missing a using directive or an assembly reference?) C:\Users\Kyle\documents\visual studio 2010\Projects\Gadgets\Gadgets\Form1.cs 341 75 Gadgets
Can some please help me fix this?
|
|
|
|
|
So where did you get the GetCurrentParent from, make it up or snaffle it from someone elses code? The error means that there is no supporting method.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Couple of things:
1. GetCurrentParent isn't a member of ContextMenuStrip
2. A context Menu item will arrive as a ToolStripDropDownItem and you will need to drill down from there to get the items you want...
Try this:
foreach (ToolStripMenuItem item in ((ToolStripDropDownItem)sender).Owner.Items)
{
if (item == sender)
item.Checked = true;
else
item.Checked = false;
}
|
|
|
|
|
Well the error I get with this is
Unable to cast object of type 'System.Windows.Forms.ToolStripSeparator' to type 'System.Windows.Forms.ToolStripMenuItem'.
So I would need to make it not notice the separator, what do you suggest?
|
|
|
|
|
Yes I would suggest ignoring any of the spearators, as you don't need to set teh check state of these...
|
|
|
|
|
ok, Is this a good way to approach this problem?
foreach (ToolStripMenuItem item in ((ToolStripSeparator)sender).Owner.Items)
{
}
|
|
|
|
|
No a better approach would be to:
foreach (ToolStripItem item in ((ToolStripDropDownItem)sender).Owner.Items)
{
if (item.GetType() == typeof(ToolStripMenuItem))
{
if (item == sender)
((ToolStripMenuItem)item).Checked = true;
else
((ToolStripMenuItem)item).Checked = false;
}
}
testing for the items type before you set teh check state of an item.
modified on Tuesday, August 24, 2010 8:41 AM
|
|
|
|
|
Thats way better but its bad because it overflows
An unhandled exception of type 'System.StackOverflowException' occurred in System.Windows.Forms.dll
|
|
|
|
|
really, the example I'm using here doesn't. I have a context menu with 3 menu items 1 separator 1 dropdown list and 1 test box ... and it seems to set the check state correctly...
Is your code a complete copy or my or have you just instered the elements you need?
I also assume that you are using this kind of approcah as you have multiple context menues and multiple menu options and only wish to have one function to do the work?
|
|
|
|
|
I put that code in and not edited it
|
|
|
|
|
ok, the only reason that you'd be getting a stack overflow from this loop is if new menu items were being added to the context menu strip, so in effect you'd be getting an ever increasing list.
That's something to check also to make sure that during each iterration of the loop that the count list count doesn't change.
As I said the example snippet I have here doesn't exhibit that issue....
Aslo as I mentioned earlier you can directly access the menu items and context menu required without looping round, for example:
myToolstripMenuItem1.Checked = true;
myToolstripMenuItem2.Checked = false;
myToolstripMenuItem3.Checked = false;
foreach (ToolStripMenuItem item in myContextMenuStrip.Items)
{
.......
}
modified on Tuesday, August 24, 2010 8:40 AM
|
|
|
|