|
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
|
|
|
|
|
I still don't know how to fix this over flow problem
|
|
|
|
|
As I mentioned something must be adding more ToolStripMneuItems to the ContextMenuStrip.Items collection.
Are you adding context menu items programmatically?
|
|
|
|
|
No I just made the strips as I did like, heres a example in visual mode
Strip1
Strip2
Strip2
Strip4
separator
Strip5
|
|
|
|
|
Ok I don't understand why you are getting a stack overflow, which is very strange...
What I would suggest then is this:
1. Turn all the items checked states off.
2. Tunr on the senders checked state...
strip1.Checked = false;
strip2.Checked = false;
strip3.Checked = false;
strip4.Checked = false;
strip5.Checked = false;
((ToolStripMenuItem)sender).Checked = true;
As you know have already defined the objects and have their names already you don't need to cycle for them, however its not as elegant as the other solution.
I'm still interested in why you getting the stack overflow, can you debug into the loop and examine ((ToolStripDropDownItem)sender).Owner.Items as this must be going up as it cycles round the loop...
And you are statically creating the items through the designer and not programtically??
|
|
|
|
|
Tip: ever heard of
is ?
...
if(item is ToolStripMenuItem)
...
|
|
|
|
|
Hello,
I am creating a mass mailing engine using C# which sends an email to many of its client. This engine includes many functionalities. One of them is tracking the email that is sent to the client (when it is opened on the emailing client like Outlook, Hotmail, Yahoo, Lotus Notes, etc., ) and also the attachments that are being downloaded by the client. All the tracking activities are to be logged into the database.
I searched many forums and got a solution of embedding 1px balnk image. I tried doing the same but i am not able to find the further steps, as to how will I actually include the entries in the db.
I am newbie to this functionality.
I would be very grateful, if anybody can help me with their small snippet of code (if any) or with the idea as to how should I go about.
Thanking you all in advance
Kind Regards
Pratik Shah.
Thanking you all in Advance
Regards
Pratik Shah
|
|
|
|
|
There isn't any way to track if an e-mail has been read if the user receiving it does not want you to know.
You could request a read receipt but the user would have to accept that it is sent to you.
Inserting an image that has to be downloaded will work but the user will still have to request that the image is downloaded, most e-mail clients will not automatically download them.
|
|
|
|