|
This is one sample Example
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=MyPhoto.jpg");
Response.TransmitFile( Server.MapPath("~/images/MyPhoto.jpg") );
Response.End();
|
|
|
|
|
This is working well for images and word documents but not for any exe file
The file gets download but its not opening
|
|
|
|
|
4anusha4 wrote: This is working well for images and word documents but not for any exe file
Obviously that code will not work for exe, that was only for image. Becuase for for exe you have to chnage the content type.
Response.ContentType = "application/exe";
|
|
|
|
|
if (e.CommandName == "download") {
Response.ContentType = "jpeg/doc/exe/jif";
Response.AppendHeader("Content-Disposition", "attachment; filename='" + sfileName + "'");
Response.TransmitFile(Server.MapPath("~/files/" + sfileName));
Response.End();
lblStatus.Text = "File is Downloaded";
}
i used like this
|
|
|
|
|
Great !
|
|
|
|
|
thanks a lot!
I found that you wrote several very useful articles, it is nice of you!
I just start learning ASP.net, hopefully, I can receive more help from you in the future!
|
|
|
|
|
You are welcome
|
|
|
|
|
I googled and googled and I'm all googled out...I can't find anything useful.
How can I add MIME types to my web setup project (i.e. Silverlight MIME types) so that it doesn't have to be added manually after the install?
|
|
|
|
|
Dear All,
I am using XP SP2 os in my pc.
I installed SQL server 2000.
and Created a Virtual directory for my deployed website.
the website runs on deplyoed mode but when i try to access database of sql server it gives an errr 'Login Failed to ABC/ASPNET user'.
i also installed VS2005 and in debug mode my wite is working fine.
what i do for it???...
In enterprise server it shows two server group Local(Windows) and ABC-SQL EXPRESS 2005. here i can access only local server group.
is it try to connect sql server 2005 Express at the time of deplyoed environment???
|
|
|
|
|
check SQL Server password.. is it correct??
|
|
|
|
|
Hello everyone.
I created a page in which user can upload images and delete as well. But the problem is if user uploads an image(fine)..n hits f5 then same image is again uploaded..which means on refreshing the upload event starts. I tried it by putting condition on upload button event !page.postback..but then user is unable to upload @ all..how i fix tis problem..
*thnx*
|
|
|
|
|
After uploading you clear the value of file upload control.....
In UI part hope so validation should be there in such a way that it should not allow user to upload file before selecting
|
|
|
|
|
Ok bt what about..delete controls and sending a message same problem i face there 2..
|
|
|
|
|
After each event redirect it to the current page itself.
if any message to display, assign the message to a session and display in the page load
give..
Response.Redirect(this.Request.Url.ToString(), false);
|
|
|
|
|
Ohh yeah..ur rite..i gt it..it will work..thnx alot!
|
|
|
|
|
I'm using a stored procedure to populate a crystal report, But I get repeatative(duplicated) information on my report- something like 66 pages instead of atleast 2. I want to produce a transactions statement for a particular user, using the crystal report, with the stored procedure getting data from multiple tables, accepting as a parameter the name of a particular client(user). Am I using the crystal report for good purpose or may be the stored procedure isn't just a way of doing it?
|
|
|
|
|
You should be able to use a stored procedure as the datasource for a Crystal report.
1) Verify that when you execute the sproc outside of crystal it is returning the correct number of rows.
2) Make sure you are not performing some join in crystal which is giving you too many unexpected row.
My vision would be that the sproc would return all of the data necessary to generate the report and you would not have to join to any other table for reference data (like user first name, last name, etc), this would make designing the report very straight forward.
Hope this helps.
|
|
|
|
|
I've got a tet box and a button on my page and am using the following code ro encrypt the URL. The only unusual part is is this line in button click event
Dim strValues As String = TextBox1.Text & TextBox1.Text & TextBox1.Text
This I was forced to do beacuse for some reason it didn't like the four digit id (i.e Invalid length for a Base-64 char array) entered into the textbox so I just repeated it three times an on the other side I just look at the first third of the decrypted querysring.
Public Function Encrypt(ByVal stringToEncrypt As String, _
ByVal SEncryptionKey As String) As String
Dim key() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(SEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes( _
stringToEncrypt)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(key, IV), _
CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Return Convert.ToBase64String(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim strValues As String = TextBox1.Text & TextBox1.Text & TextBox1.Text
Dim strURL As String = "PasswordReset.aspx?Key=" & Encrypt(strValues, "!#$a54?3")
Response.Redirect(strURL)
End Sub
My decyption code is:
Public Function Decrypt(ByVal stringToDecrypt As String, _
ByVal sEncryptionKey As String) As String
Dim key() As Byte = {}
Dim IV() As Byte = {&H12, &H34, &H56, &H78, &H90, &HAB, &HCD, &HEF}
Dim inputByteArray(stringToDecrypt.Length) As Byte
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
inputByteArray = Convert.FromBase64String(stringToDecrypt)
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateDecryptor(key, IV), _
CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
Return encoding.GetString(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function
Everthing works great EXCEPT when I try to decrypt the number 305930593059 (this is 3059 repeated three times). When executing the line: inputByteArray = Convert.FromBase64String(stringToDecrypt) I error out with "Invalid length for a Base-64 char array". Any other number that I try, even 5 digit ones, work fine.
Is this wierd or what?
Thanks in advance for any help.
|
|
|
|
|
Please post your code with proper formatting inside pre tag :
like,
CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
It will then readable easily.
Thanks !
|
|
|
|
|
I have been browsing and searching for articles on above topic. I didn't find equivelant and decided to ask if someone knows if there is article on that topic.
I created a DLL library that has few ASP.NET components inside to be placed on ASP.NET site. The whole point of the library is that it is movable (from any server, any folder etc.) and it has no outside resources/additions it needs. This is also the reason why IHttpHandler wasn't used. So, I needed to create an image control inside the librarys component that streams different images from its resouces. How I overcame this all was that my own image controls render method wrote img-tag to the output. Img-tags url was pointing to the control itself with a parameter. The parameter was the name of the picture. When the browser tries to load the img-tag it finds itself again in the same control from the library. On this second time, the page load method writes to Response the binary output of an desired image.
I was just wondering should I write an article of that briefly described techinque. After all, I needed to come up with some own stuff not present in any article I came up / found earlier. And yes, it uses double call to show an image but on this case, this wasn't a problem.
So, this post is just to get an indication if one article already exists and do people think that the article out of above described would be needed by someone else than me. Thanks in advance for your replies.
|
|
|
|
|
Hi,
i have the following code:
<asp:GridView ID="GridViewDetailLocuriMunca"
runat="server"
AutoGenerateColumns="False"
DataKeyNames="id"
DataSourceID="LocuriMuncaDataSource"
AllowPaging="True"
AllowSorting="True"
OnRowUpdating="GridViewDetail_RowUpdating"
Caption="Locuri de munca">
<Columns>
<asp:CommandField
ShowEditButton="True"
ButtonType="Image"
<asp:TemplateField HeaderText="grupa" SortExpression="grupa_cod" Visible="True">
<edititemtemplate>
<asp:DropDownList ID="DropDownListGrupaEdit"
runat="server"
DataSourceID="CodGrupaLocuriMuncaDataSource"
DataTextField="cod"
DataValueField="id"
AutoPostBack="true"
SelectedValue='<%# Bind("grupa_id") %>'>
</asp:DropDownList>
</edititemtemplate>
<ItemTemplate>
<asp:Label ID="grupa_cod"
runat="server"
Text='<%# Bind("grupa_cod") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="comp." SortExpression="comp_cod" Visible="True">
<ItemTemplate>
<asp:Label ID="comp_cod"
runat="server"
Text='<%# Bind("comp_cod") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownListCompEdit"
DataTextField="Cod"
DataValueField="ID"
DataSourceID="SqlDataSourceComp"
AutoPostBack="true"
EnableViewState="true"
OnDataBound="myDataBoundComp"
runat="server"
Enabled="True" />
<asp:SqlDataSource runat="server" ID="sqlDataSourceComp"
ConnectionString="<%$ ConnectionStrings:DecontariConnectionString %>"
SelectCommand="SELECT comp.cod, comp.id FROM [nGrupeLocuriMunca] lm, [nCompartimente] comp WHERE (comp.id = lm.comp_id AND lm.id = @grupa_id)"
>
<SelectParameters>
<asp:ControlParameter
Name="grupa_id"
ControlID="DropDownListGrupaEdit"
PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="centru cost" SortExpression="cc_cod">
<ItemTemplate>
<asp:Label ID="cc_cod"
runat="server"
Text='<%# Bind("cc_cod") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="ddlCentreCost"
DataTextField="Cod"
DataValueField="ID"
DataSourceID="SqlDataSourceCC"
AutoPostBack="true"
EnableViewState="true"
OnDataBound="myDataBindCost"
runat="server"
Enabled="True" />
<asp:SqlDataSource runat="server" ID="sqlDataSourceCC"
ConnectionString="<%$ ConnectionStrings:DecontariConnectionString %>"
SelectCommand="SELECT cc.cod cod, cc.id id FROM [nCentreCost] cc, [nCompartimente] comp WHERE (cc.cp_id = comp.cp_id AND cc.activ = 1 AND comp.id = @comp_id)"
>
<SelectParameters>
<asp:ControlParameter
Name="comp_id"
ControlID="DropDownListCompEdit"
PropertyName="SelectedValue"
/>
</SelectParameters>
</asp:SqlDataSource>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and my problem is that when i change the value for the first list: DropDownListGrupaEdit, only the second
list is updated: DropDownListCompEdit ... The last one does not refresh at all, but only when i try to select a value that is not actual in the list ...
How can i solve this issue ?
|
|
|
|
|
Hi,
I am taking some formula expression from database, after i have to eveluate the expression into VALUE. the Expression as like as below,
1) BASIC + HRA + DA
2) 3000 + ABS(2000) + Round(Basic)
3) BASIC + iif((BASIC > 1000), 2000, 1000) + 3000
The Above are Formula expression already comming from database.
i copied these expression to a string varable, then i am trying to evaluate all the mathematical expression like ROUND, ABS are giving value but IIF is not returns value ...So how to resolve this Expression...
I am clearly mentioned my problem,.. if any clarification necessary plz dont hesitate to ask ..i will tell more clearly..
regards,
kannak
|
|
|
|
|
Marking your post as Very Urgent is very rude around here. It may be urgent to you but everyone here volunteers their time, it's not urgent to them
only two letters away from being an asset
|
|
|
|
|
Kannak,
You menitioned that ROUND,ABS etc you are able to do. So you know the meaning of string "ABS" is the mathematical expression ABS.
So you should be knowing the meaning of string "IIF".
Based on the meaning you have to implement. Supposr, I think the meaning is the maximum of the 3 values then I would have a function like this -
private int GetValueFromIIF(string iifCond)
{
string[] strValues = iifCond.Split(',');
int[] intValues = new int[3];
int maxValue = -1;
for(int i = 0; i < strValues.Length;i++)
{
intValues[i] = Convert.ToInt32(strValues[i]);
if (intValues[i] > maxValue)
maxValue = intValues[i];
}
return maxValue;
}
|
|
|
|
|