|
|
This will not work. You need to read the header of the image, after that read all the contents, and then assign it to the variables.
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
This will not work. You need to read the header of the image, after that read all the contents, and then assign it to the variables.
regards
sAqIb
"Our scientific power has outrun our spiritual power. We have guided missiles and misguided men."
Dr. Martin Luther King Jr.
|
|
|
|
|
I think do you not send any content to client. Where in code did you write content to imageStream.
|
|
|
|
|
Sir,
Can u please explain the difference between response.redirect and Response.Transfer with the help of a single simple example.
Thanks
|
|
|
|
|
Redirect and Transfer both cause a new page to be processed, but the interaction between the client (web browser) and server (ASP.NET) is different in each situation.
Redirect: A redirect is just a suggestion – it’s like saying to the client “Hey, you might want to look at this”. All you tell the client is the new URL to look at, and if they comply, they do a second request for the new URL.
If you want to pass state from the source page to the new page, you have to pass it either on the URL (such as a database key, or message string), or you can store it in the Session object (caveat: there may be more than one browser window, and they’ll all use the same session object).
Transfer: A transfer happens without the client knowing – it’s the equivalent of a client requesting one page, but being given another. As far as the client knows, they are still visiting the original URL.
Sharing state between pages is much easier using Response.Transfer – you can put values into the Context.Items dictionary, which is similar to Session and Application, except that it lasts only for the current request. (search for HttpContext in MSDN). The page receiving postback can process data, store values in the Context, and then Transfer to a page that uses the values.
Regards,
Satips.
|
|
|
|
|
That sounds like you copied a question from a test... I can explain the difference, but if you need it in some special form, that is up to you.
Response.Redirect will send the browser a response that is a redirection page to the URL that you specify. The URL can be any resource anywhere.
Server.Transfer stops execution of the current page and executes the page that you specify as part of the current response. The page has to be on the same server.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
Am getting this error in the Button click event after entering the credentials, not getting this error each time i click. I searched for this in
all the msdn, blogs, asp.net forums etc... They r saying to register the event. I did the same by writing the following code
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(Login1.UniqueID);
base.Render(writer);
}
But there is no use still am getting the same error even after registering the event too. Can anyone help me how to overcome this problem.
Thanks in Advance!
|
|
|
|
|
In your web.config on the page tag set EnableEventValidation=False
|
|
|
|
|
Thanks for reply!
This is the security issue right. I cant do that.
Can I Have Other solution for this?
Thanks!
|
|
|
|
|
help me!
when i use Response.Redirect how do i determine the target ?
i want that my page open in the main frame in my page?
when i use the link we can the target by target="main"
but in this case ...?
what can i do?
ava_h
|
|
|
|
|
You can't determine the target. The target was determined already when the request was sent to the server, so it's too late to change the target.
You either have to change the target before the request is sent from the browser, or you have to send a response that is a page that contains Javascript that will make the browser send a new request with the target you want.
---
b { font-weight: normal; }
|
|
|
|
|
I have recieved no answer from my previous query but I do have more information so hopefully I someone may have some more information for me. (For a quick reminder I am creating an ASP.NET control to upload n number of files and as part of that I am using Javascript to dynamically generate file inputs through the DOM)
When uploading a file through ASP.NET the encoding type of the form must be "multipart/form-data" which I already knew, however, it must be the HtmlForm for the page that is set and not just any form. (http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlform.aspx, and http://msdn2.microsoft.com/en-us/library/system.web.ui.htmlcontrols.htmlinputfile.aspx)
A simple loop through Page.Controls reveals the HtmlControl for the page if there is one. (Surprise there is no method to return it! so you must roll your own) With this set I am still unable to upload files!
Now here is where it gets really interesting: If I add <input type="file" id="thisIsATest" runat="server"/> somewhere in my user control everything works even though I am not using the thisIsATest element for the upload. I can't find any meaningful difference in the HTML source between the two.
Any ideas?
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: A simple loop through Page.Controls reveals the HtmlControl for the page if there is one. (Surprise there is no method to return it! so you must roll your own) With this set I am still unable to upload files!
You can use the HttpRequest.Files Property [^] to access the uploaded file collection.
Ennis Ray Lynch, Jr. wrote: I can't find any meaningful difference in the HTML source between the two.
The difference is that the HtmlInputFile marked with runat="server" will set the Enctype = "multipart/form-data" for the form element if this property is empty.
|
|
|
|
|
Heh, the problem is the HttpRequest.Files.Property does not get populated when you generate your own html code using Javascript and DOM even if you set the enctype.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: HttpRequest.Files.Property does not get populated when you generate your own html code using Javascript and DOM even if you set the enctype.
Yes, it does.
|
|
|
|
|
I may seem like a moron but I am not, I have actually been working on this for quite a while. When I generate input type of file using javascript they are not uploaded on the post even when the encType is properly set unless I have placed one using the designer.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
![Go to Parent](https://www.codeproject.com/App_Themes/CodeProject/Img/arrow-up24.png) Below is a quick example:
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void btnUpload_Click(object sender, EventArgs e)
{
Response.Write(string.Format("Files uploaded: {0} <br/>", Request.Files.Count));
HttpFileCollection files = Request.Files;
for(int index=0; index<files.Count; index++)
{
Response.Write(string.Format("Filename: {0} size: {1} <br/>", files[index].FileName, files[index].ContentLength));
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Dynamic upload</title>
<script type="text/javascript">
var iCount = 0;
function AddInputFile()
{
iCount++;
var inputFile = document.createElement("<input type='file' id='file" + iCount +"' name='file"+ iCount +"' />");
var br = document.createElement("<br/>");
var container = document.getElementById("divInputFile");
container.appendChild(inputFile);
container.appendChild(br);
}
</script>
</head>
<body>
<form id="form1" runat="server" enctype="multipart/form-data">
<div id="divInputFile">
</div>
<button on_click="AddInputFile();">Add New Upload</button>
<asp:Button runat="server" ID="btnUpload" Text="Upload" On_Click="btnUpload_Click" />
</form>
</body>
</html>
|
|
|
|
|
That is nearly identical to what I have. Yet for some reason it does not work. The only way I can get it to work is to type out
<br />
<input type="file" runat="server" id = "blah" /><br />
Somewhere in the html in the aspx page. If that isn't there the upload doesn't work! That is why I am so troubled, it is supposed to work.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Which .NET version did you write your code in? I am writing in 1.1 at work which is were I am having the problem.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Ennis Ray Lynch, Jr. wrote: Which .NET version did you write your code in? I am writing in 1.1 at work which is were I am having the problem.
I'm doing the version 2.0 (v2.0.50727), I'll try in the version 1.1 then.
|
|
|
|
|
It works just fine with the v1.1.4322 version.
|
|
|
|
|
I will just try backing out until it works (hopefully). Thanks for checking for me, btw. I think it might be related to the form tag then.
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
Your html head is marked as runat server, does that mean AddInputFile is running at the server?
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|
|
ASP.NET will autogenerate a name element for all controls created on the server-side and the HTML spec, http://www.w3.org/TR/html4/interact/forms.html#successful-controls[^], states the name is required for Successful controls and only successful controls are required to be posted back.
To make it weird it seems browser agents still group by id for a post so input elements with the same id are submitted if at least one has a name? Neat. So, if you want to dynamically generate input elements in client-side java script you must include the name attribute in the input element tag!
On two occasions I have been asked [by members of Parliament], 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question. - Charles Babbage
|
|
|
|