|
Welcome
|
|
|
|
|
Member 3113225 wrote: Thanks Abhijit
this article really solved my problem. thanks again.
Then Mark it as Answer
|
|
|
|
|
Hello Guys...
I have some problem
I had a array of byte all ready
call it xByte
xByte contain single file of any type which had been converted on server into byte()
I had link button
i want to when i click it the browser will download the file
just like download file dialog....
how i manage to do that...
please help me
i really appreciate it....
Thanks......
|
|
|
|
|
I think..! You Have to Specify the Content type And try to display THt.
For Image
byte[] arrContent = null;
arrContent = (byte[])dr["photo"];
int length = arrContent.Length;
Response.ContentType = "image/JPEG";
if (length!=0)
Response.OutputStream.Write(arrContent, 0,length);
Response.End();
or
Any File You have zip it and give them a download option..!
|
|
|
|
|
sashidhar wrote: Response.End();
You should be very careful while using Response.End() in your Code !!!
|
|
|
|
|
Thx For Your Suggestion
Abhijit Jana wrote: Response.End()
Is There any Drawbacks?Can You Let Me Know..!
|
|
|
|
|
The Response.End() method causes the Web server to stop processing for further request .
|
|
|
|
|
Abhijit Jana wrote: The Response.End() method causes the Web server to stop processing for further request .
That is not true. All it does is stop execution of page and return the buffered output. It doesn't affect further requests.
|
|
|
|
|
Yes, I want to mean that only. "Stop Processing of Further Request". . And it is understandable that it will return the buffer out put as he is writting it on output stream !!
modified on Thursday, October 1, 2009 3:34 AM
|
|
|
|
|
u can use this code piece for it.
Response.Buffer = true;
Response.AddHeader("Content-Disposition", "attachment;filename=" + strFileName);
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "utf-8";
Response.BinaryWrite(xByte);
Response.End() ;
this code piece will present a open/save/cancel dialog.
|
|
|
|
|
Hey nisha
thank for your guidance
sorry to bother you again
but what if we dont know what the file type is
because all user can upload any kind of file type
instead of display it onto browser
i just want to display download file dialog...
On your code there was ms.excel type...
What if i just know the extention
not the content type
im sorry for my unknown
|
|
|
|
|
So u are allowing users to download file that is uploaded by themselves. In this case there are two possibilities , either u are storing the file at hard disk or in database.
CASE 1 Saving File At HARD DISK
In this u can identify the Application type via file type. I means whether it's a pdf , doc, txt, xls or .jpg. Just put a Switch case over there and do a dance of joy.
CASE 2 Saving File Content in DATABASE
In this case u need to store the Application type in the database while adding record for that file. Again u have a file type so get the Application type using switch case.
|
|
|
|
|
CASE 1 Indeed
I save the filename and type in separates data...
|
|
|
|
|
I forget to tell you
im using ajax enabled website
|
|
|
|
|
|
11Developer wrote: I want to place captcha image on HTML page by using ASP code not ASP.net code.
Then what you are doing over here ? This ASP.NET Forum. Better ask this query at Web Development Forum !
|
|
|
|
|
11Developer wrote: I want to place captcha image on HTML
Please Ask Your Question in different Forum ..!
This Is Asp.net forum
|
|
|
|
|
It seems, you have joined CP today !! So please read forum guide line before you post anything. Everybody here to help you out !! Deleting messges, down voting message does not help you !!
Please read forum guide line !!!
|
|
|
|
|
Hi all!
I looked and I searched and I came out empty... I am trying to do what should be a straightfoward task: update the value of a HiddenField and use that client side in a script. Here is the scenario:
- User goes to a page that has a Cancel button
- If the user changes anything at all on the page (adds items to a grid, changes textfields, etc.) I want the Cancel button to return a confirmation ("Are you sure you want to continue? Your changes will be lost.")
The elements on the page (textboxes, grid, etc) are all in an AJAX UpdatePanel. The Cancel button calls a javascript function which checks the value of a HiddenField to figure out whether to display the confirmation or not.
So, here's what I have so far:
My Cancel button:
<asp:ImageButton ImageUrl="~/images/ButtonCancel.png" style="float:right" OnClientClick="return RequestMessage();"
ID="btnCancel" CssClass="button" runat="server" OnClick="btnCancel_Click"
CausesValidation="False" />
The javascript function behind the OnClick event:
<script type="text/javascript">
function RequestMessage()
{
if($get("ctl00_BodyPH_ConfirmationMsg").value=="true")
{
return confirm('Are you sure you want to continue? Your changes will be lost.')
}
else
return true;
}
</script>
The HiddenField is defined inside the UpdatePanel:
<asp:HiddenField runat="server" ID="ConfirmationMsg" Value="true" />
And it is registered in the protected override void Render(HtmlTextWriter writer) event:
ScriptManager.RegisterHiddenField(this.Page, ConfirmationMsg.ClientID, "false");
When I look at the code generated on the client side the HiddenField seems to be correctly registered as such:
<input type="hidden" name="ctl00_BodyPH_ConfirmationMsg" id="ctl00_BodyPH_ConfirmationMsg" value="false" />
So everything is good so far. The problem comes when I try to change the value of the HiddenField from various events, such as a simple TextBox_TextChanged event:
protected void txtCustomerID_TextChanged(object sender, EventArgs e)
{
ConfirmationMsg.Value = "true";
loadCustomerInfo(false);
}
The event fires but the value for the HiddenField never changes client side, it always stays "false". How can I updated this value throughout the code so that the confirmation will show correctly?? Or am I going about this the wrong way? Is there a better way of achieving the same task another way?
Thanks very much for any insight into this!
|
|
|
|
|
IMO, server side events should not be used like you did. This can be achieved with a client side script. Hook JS OnChange event handler to the text box and change the hidden text box value inside that.
If you are handling this on client side, you don't even need a hidden text box. A JS variable declared in a script block should do the trick. It acts as a public variable available to the whole page. When text changes, just set the value into this variable.
Ramon Enachescu wrote: if($get("ctl00_BodyPH_ConfirmationMsg").value=="true")
This is bad. You should not hard code client id into the code. Either use ClientId property of the control or $get("ConfirmationMsg", parent_control_id) .
|
|
|
|
|
Thanks Navaneeth,
The reason I went with the server side event is that I have to update this flag from many places, so instead of writing JS for a whole bunch of events (text changed, button clicks, grid events [adding/deleting/updating], etc) I'd rather just set a tiny little flag when I need to . I can't be the first one looking for functionality like this...
And yes sir, no hardcoding, that's there cause I'm still trying out things and this is by no means final code but thanks for noticing .
|
|
|
|
|
In my gridView table
Column 'Issue' has a long string (i.e: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx)
how can i wrap it so it wont expand my table, or squeez down other columns?
i had tried ItemStyle Wrap="true", but it doesn't work
|
|
|
|
|
The word doesn't wrap if there is no space in between. However you can manually insert <br /> tags on the string by writing a function and call it from the html.
|
|
|
|
|
I'm developing a TabStrip control and am having a bit of an issue with the designer and child controls. Below is the relevant code in regards to the problem (I can provide more if needed).
[ParseChildren(true), PersistChildren(false)]
[ToolboxData("<{0}:TabStrip runat=server></{0}:TabStrip>")]
public class TabStrip : CompositeControl, IPostBackEventHandler
{
private Tab mySelectedTab;
private TabCollection myTabs;
public TabStrip()
{
this.myTabs = new TabCollection(this);
}
[MergableProperty(false)]
public Tab SelectedTab
{
get
{
foreach (Tab tab in this.Tabs)
if (tab.IsSelected)
return tab;
return null;
}
set { value.IsSelected = true; }
}
[PersistenceMode(PersistenceMode.InnerProperty), NotifyParentProperty(true)]
[MergableProperty(false)]
public TabCollection Tabs
{
get { return myTabs; }
}
}
When I add tabs to the Tabs property on a page using the property grid's collection editor the tabs are listed in the collection editor by ID and can also be selected from a drop-down list from the property grid for the SelectedTab property. This is good and is exactly how I want the control to behave in the designer. The problem is, when the page is closed and reopened in the designer, the markup is still there, but when editing the child tabs in the collection editor they are listed by there class name rather than ID, changes made in the collection editor are not persisted, and they are no longer listed in the drop-down for the SelectedTab property. This is no good.
The TabCollection class implements the IList interface and all the Tab 's public properties have the NotifyParentPropertyAttribute set to true. Please advise as to what may be missing for the designer to be aware of the child controls when the page containing the control is reopened. Thank you.
|
|
|
|
|
The designer is evil. Do not use it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|