Showing posts with label select. Show all posts
Showing posts with label select. Show all posts

Saturday, March 24, 2012

Uploading file during onchange

I try to upload file in server during user select file:

<inputid="iupload"runat="server" type="file"style="width:1px"/>
<inputtype="hidden"id="hdName"runat="server"/>

<scriptlanguage="javascript">
function Doo(){
document.getElementById('hdName').value = document.getElementById('iupload').value;// to check path
WebForm_DoCallback('__Page',document.getElementById('iupload').value,CallbackFunction,'context',null,false);returnfalse;
}
</script>

and on server side:

protectedvoid Page_Load(object sender, EventArgs e)
{
string argClientFunction ="";
string cScript = ClientScript.GetCallbackEventReference(this, argClientFunction,"CallbackFunction","'context'","null",false);
string f=@dotnet.itags.org."
javascript:Doo();";
iupload.Attributes.Add("onchange", f);

string scr ="<script language=javascript>";
scr +="function CallbackFunction(result, context)";
scr +="{";
scr +="document.getElementById('spUploaded').innerText += 'Done';";
scr +=" return false;";
scr +="}";
scr +="</script>";
RegisterStartupScript("scr" +this.ClientID, scr);

}


publicvoid UploadFile(string fileName)
{
// try to upload file to server
}
publicstring GetCallbackResult()
{
UploadFile(evArg);

evArg = String.Empty;

return evArg;
}
publicvoid RaiseCallbackEvent(string eventArgument)
{
evArg = eventArgument;
}

Problem occur in UploadFile(...): When I try to get iupload.PostedFile for file uploading it's null. I can get file name only.

How can I upload file normally without postback with onchange ?

I need upload file to server as Gmail or Yahoo Mail!

File uploads require a full postback. There has been a lot of talk on here about sites such as gmail that appear to asynchronously load a file. At this point, the only way that I have heard of this successfully implemented is by using IFrames and have another page that does the full postback, but doesn't look like it.


Thank you! I have heard about Iftame to upload files. Have you any information about this?


Not really... we haven't got into handling file uploads very often, and if we do, we would probably use the telerik fileupload control since we have the suite and I believe it handles very large files much better that the built in fileupload for asp.net. When I tested both of them, I was able to crash IIS with the built in control by trying to upload a dvd image because it seemed to check for the file size only after it had been processed through IIS, but the telerik control seemed to do that in pieces which didn't cause it to lock up.

Wednesday, March 21, 2012

Usage of CallBack Implementation in TAB Control of AJAX

The requirement is like i have to select different selection criteria in different tabs of tab control of ajax.

i have implemented call back functionality in one tab for getting the values of gridview dynamically. in the first tab its all working fine.

but the thing is call back implementation is getting the same value from the selected row of gridview in all tabs.

So can u do the needful so that i can able to get different selected values of gridview in different tabs of tab control using call back implementation.

Hi,

Thank you for your post!

But I am afraid I cann't understand you well, would you please provide with any code or a simple repro?

Best Regards,