|
pujafaldu wrote: MemoryStream stmContent;
stmContent = new MemoryStream(reportFile);
using(MemoryStream memStream = new MemoryStream(firstString.Length))
{
memStream.Write(reportFile, 0 , reportFile.Length);
Attachment attachFile = new Attachment(stmContent,strfileName);
mail.Attachments.Add(attachFile);
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi...
i have made changes according to you.but it not works...
here is the changed code.
byte[] reportFile = (byte[])row1["Content1"];
string strfileName = row1["FileName"].ToString();
MemoryStream stmContent;
stmContent = new MemoryStream(reportFile);
using (MemoryStream memStream = new MemoryStream(reportFile.Length))
{
// Write the first string to the stream.
memStream.Write(reportFile, 0, reportFile.Length);
Attachment attachFile = new Attachment(stmContent, strfileName);
mail.Attachments.Add(attachFile);
}
|
|
|
|
|
This is incorrect. You should not dispose stream before sending the mail.
|
|
|
|
|
Are you getting data correctly into the byte array? You are using this[^] constructor of attachment class where the second parameter is name of the content type not the file name. You need to specify a content type which says the data is image.
|
|
|
|
|
I am using this code to generate Treeview dynamically from the database.....output is coming but...not as desired.....means Category's connected field are coming to Sub-Category1 and Sub-Category1's field are showing in Sub-Category2..........plz chk and let me know whether the loop is rite or not? code is:
Dim ParentNode As String(,) = New String(100, 2) {}
Dim count As Integer = 0
Dim db As Database = DatabaseFactory.CreateDatabase("See2Buy")
Dim cmd As String = "Select CategoryID, CategoryName From Cat ORDER BY CategoryID"
Dim rdr As IDataReader = db.ExecuteReader(CommandType.Text, cmd)
While rdr.Read()
ParentNode(count, 0) = rdr.GetValue(rdr.GetOrdinal("CategoryID")).ToString()
ParentNode(System.Math.Max(System.Threading.Interlocked.Increment(count), count - 1), 1) = rdr.GetValue(rdr.GetOrdinal("CategoryName")).ToString()
End While
'rdr.Close()
For [loop] As Integer = 0 To count - 1
Dim root As New TreeNode()
root.Text = ParentNode([loop], 1)
'root.Target = "_blank"
root.Value = ParentNode([loop], 1)
root.NavigateUrl = "SubCat1.aspx?id=" + root.Value
Dim cmd1 As String = " Select SubCat1ID, SubCategoryName from SubCat1 where CategoryID =" & ParentNode([loop], 0)
'Dim Module_Sdr As SqlDataReader = Module_SqlCmd.ExecuteReader()
Dim rdr1 As IDataReader = db.ExecuteReader(CommandType.Text, cmd1)
While rdr1.Read()
Dim child As New TreeNode()
child.Text = rdr1.GetValue(rdr1.GetOrdinal("SubCategoryName")).ToString()
root.ChildNodes.Add(child)
Dim cmd2 As String = " Select SubCat2ID, SubCategoryName from SubCat2 where CategoryID =" & ParentNode([loop], 0)
Dim rdr2 As IDataReader = db.ExecuteReader(CommandType.Text, cmd2)
While rdr2.Read
Dim child2 As New TreeNode()
child2.Text = rdr2.GetValue(rdr2.GetOrdinal("SubCategoryName")).ToString()
child2.Target = "_blank"
child2.NavigateUrl = "Default.aspx"
child.ChildNodes.Add(child2)
End While
End While
rdr1.Close()
TreeView1.Nodes.Add(root)
TreeView1.CollapseAll()
Next
|
|
|
|
|
Your whole design is broken. You should just set the parent id of each child, not have a seperate table for each level. Beyond that, you should step through your code to try to work out what is wrong.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
I have been noticing that you have been trying to do this for almost a week now.
Every time you come up to the CP for the next step.
In between, do you mind to put your code in PRE tag from next time it makes lives simple to read and understand the code.
As far as your code is concerned, I do not understand why did you make it this complex. I gave you SQL query hint [^]to get all the categories and sub categories from database.
Did you try that approach? I am sure it would have simply solved your problem of you would have gone step by step for you goal
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Thanks for ur Code Mr. Manas that u gave me last time.....but that was showing just a single Category and single Sub-Category......thats why i did this one.........I am a new guy thats why comes to CP
|
|
|
|
|
As I understood, you need to create a tree of categories where each category may be a child and/or a parent to another .. if so,
- You need 2 columns in the Categories table, (CategoryId, ParetntId)
both must be of the same data type
- Then you have to set the CategoryId as PK, and ParentId as FK from the table itself
- Now we have finished the server side work.
- on the client side, you may load the table into a dataset object (name it CategoriesDataSet )
- To display the data on the tree control, no need for loops
- Just set the following properties to the tree control
DataSource = CategoriesDataSet<br />
ParentId = ParentId<br />
FieldId = CategoryId
Finally call DataBind()
foreach(Minute m in MyLife)
myExperience++;
|
|
|
|
|
Hi Guys
In ASP.Net 2.0 application i am using ajax(toolkit Script manager)
In My Application there are two panel, On Page load one panel visible is true After Click On A button, first Panel Visible= False and second panel visible = true
on second panel there is a start button
After Click On that Button i am getting this Error
while In IE 6.0 this application working perfectally
Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 0
What will be solution for that
Please Help Me
Thanks In Advanced
krishna veer singh
|
|
|
|
|
|
I Implemented it
but its not working
so any other solution, SIR
krishna veer singh
|
|
|
|
|
Hi,
I am a beginner in .Net.
In my application i have 4 panels.
But,during postback(such as a button click event),the focus automatically goes to the first panel.
In web,i found on idea to use TabbedPanels1.showPanel(tabindex) on button's onclick event.
But,both in the OnClientClick and OnServerClick events i have written the validation and some task to be done respectively.
How to persist the focus on the panel during postback?
Thanks in advance
Yazhini
|
|
|
|
|
YazhiniP wrote: But,both in the OnClientClick and OnServerClick events i have written the validation and some task to be done respectively.
You should always do validation on the server side, don't trust the client validation.
If there's no server side focus method to call, then you need to write javascript to do it.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Hi all ,
How i deal with the File Uplad control in View control . i placed the Fileuplaod control on view control .
Is Fileupload stored data in viewstate like others controls inside view control ?
Any Idea or link ?
Best Regards
|
|
|
|
|
Rameez Raja wrote: Is Fileupload stored data in viewstate like others controls inside view control ?
No. It's a html file input control, it's data is sent to the server, but it's not stored in viewstate.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Thanks for reply ,
It is server side control not the html file input control if not then kindly suggest me how i deal with fileupload control issue in view control ?
Best Regards
|
|
|
|
|
Rameez Raja wrote: It is server side control not the html file input control
There is no such thing as a server side control, on the client. The 'server side control' is rendered as a html control, that's all it could ever be. whatever happens, on postback, your control will contain the bytes of your file and it's name. viewstate is for persisting values between postbacks, a file is assigned, sent on that postback and forgotten.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Christian Graus wrote: There is no such thing as a server side control, on the client. The 'server side control' is rendered as a html control, that's all it could ever be. whatever happens, on postback, your control will contain the bytes of your file and it's name. viewstate is for persisting values between postbacks, a file is assigned, sent on that postback and forgotten.
Thanks for reply,
Ok iam agreed with you now how i deal with uplaoding the image may i have to store in folder Temprarly and called during displaying summary am i right ?
Suggest me good option to deal with uploading .
Best Regards
|
|
|
|
|
Yes, you need to write it to the file system if you want to display it after uploading.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Dear colleges,
I have the following case:
1. web_page.aspx, using UC1.ascx
2. When this page is launched, after user does some things (selects settings), I need to launch web_page2.aspx from UC1.ascx with some parameters.
3. web_page2.aspx uses another user control (UC2.ascx), which needs the parameters passed from step 2 (from UC1.ascx).
Bottom line:
1. I need to pass parameters from UC1.ascx to web_page2.aspx.
2. The I need to pass these parameters from web_page2.aspx to UC2.ascx
I tried the following, which I know will not serve my needs:
In my UC1.ascx:
<br />
object[] constructorParameters = new object[1];<br />
<br />
constructorParameters.SetValue(SocketUserSettings, 0);<br />
<br />
List<Type> constParamTypes = new List<Type>();<br />
foreach (object constParam in constructorParameters)<br />
{<br />
constParamTypes.Add(constParam.GetType());<br />
}<br />
<br />
UserControl ctl = Page.LoadControl("UC2.ascx") as UserControl;<br />
System.Reflection.ConstructorInfo constructor = ctl.GetType().BaseType.GetConstructor(constParamTypes.ToArray());<br />
<br />
if (constructor == null)<br />
{<br />
throw new MemberAccessException("The requested constructor was not found on : " + ctl.GetType().BaseType.ToString());<br />
}<br />
else<br />
{<br />
constructor.Invoke(ctl, constructorParameters);<br />
}<br />
And inside UC2.ascx constructor I did:
<br />
public SocketConnectionList(SocketParam SocketUserSettings)<br />
{<br />
m_propertiesSet = true;<br />
m_SocketUserSettings = SocketUserSettings;<br />
Response.Redirect("SocketConnectionListPage.aspx");<br />
}<br />
The problem with this code is that launching an aspx from a user control will cause launching another instance of user control for the page launch and hence the parameters passed are not accessible for the second instance.
Please you help is appreciated.
|
|
|
|
|
Don’t you think the approach you are using is a bit complicated?
You can rather create a public property in the User Control(UC1). Set this property when you load this control on Page1. This way you already passed the information to the control.
In the second scenario, make user of hidden variables/query string to pass on the information.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Thanks, but I am still not clear.
I have the info I need in UC1.ascx already.
I need this information to be passed to web_page2.aspx (which in it's turn should pass it to UC2.ascx).
You have mentioned hidden variables, what does that means?
Do you have a simple example showing that (even pseudo would fit fine).
Thanks for the prompt reply!
|
|
|
|
|
When a User Control is loaded into a web form, it becomes part of the WebPage itself. So you need to look at it from that perspective and not from a Design time angle.
That means whatever information is available to Web Form2 can be easily accessed by UC2 too.
Hidden Variables[^]
Query Strings[^]
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hello
What was known as "Web Control Library" for ASP.NET is no longer continued in VS2005/2008 am I right?
I think I remember I used tree control from the library some years ago...
dev
|
|
|
|