Dude you are confused with your requirement... First thing you cant write intermediate responses when you are still calculating something on server.
Listen whatever conditions you had , if one fails at the same time you send response back and you dont have to still calculate anything. so when any first condition fails , you will get the respone in your ajax on succeed or failure function , there first
you will hide the loading image and alert the message with the correct data passed from user , whatever it is like "pla input file within max-size limit 10 MB" etc
Please if your thread get resolved ,'Mark as Answer' to reflect the right status.
__________________________________________________
ARMY: Reason to PROUD
What you do , on upload call function which will do ajax call like this (using jquery here).
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "Index.aspx/GetOrdersForApproving",
data: "{ }", // send an empty object for calls with no parameters
dataType: "json",
success: function (msg) {
// Notice that msg.d is used to retrieve the result object
},
failure: function (msg) {
// Notice that msg.d is used to retrieve the result object
}
});
Here in the so during each condition , you returned response to server with data , so than from success function , you can call different web method for different condition and process or the same webmethod by passing parameter which tells first condition already checked now check 2nd and return response. its easy dude. you can implement it. during this you can keep the image loading till final cal , so there will be no of nested ajaz calls based on the number of conditions you have.
Please if your thread get resolved ,'Mark as Answer' to reflect the right status.
__________________________________________________
ARMY: Reason to PROUD
dataType:"json", success:function(msg){ // Here if first condition passed , you returned reponse from server with specific parameter which tells first condition pass and you can show alert here , now make anothe ajax call from inside of this function with specific parameter to webmethod which will check for next condtion. so in this way you have n no of nested ajax calls based on n no of your conditions}, failure:function(msg){ // Alert message to user to upload file again } and again follow the same thing });
Please if your thread get resolved ,'Mark as Answer' to reflect the right status.
__________________________________________________
ARMY: Reason to PROUD
Dude ultimately what those update progress controls are doing in background is the thing i mentioned , nested ajax calls , if you implement that way it will be much faster.
Please if your thread get resolved ,'Mark as Answer' to reflect the right status.
__________________________________________________
ARMY: Reason to PROUD
softvishu
Member
460 Points
120 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 09:41 AM|LINK
Dude you are confused with your requirement... First thing you cant write intermediate responses when you are still calculating something on server.
Listen whatever conditions you had , if one fails at the same time you send response back and you dont have to still calculate anything. so when any first condition fails , you will get the respone in your ajax on succeed or failure function , there first you will hide the loading image and alert the message with the correct data passed from user , whatever it is like "pla input file within max-size limit 10 MB" etc
__________________________________________________
ARMY: Reason to PROUD
Thanks,
Vishal Sharma
Ajay2707
Contributor
4421 Points
856 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 11:00 AM|LINK
Hi Shivanand,
check this.
<script> var messageText; function checkMessage(){if (messageText!=null)alert(messageText);} </script> <body onload="checkMessage();">and in code-behind:
Response.Write ("<script>messageText=""Hello world""</script>");return;
So the same thing you can for file upload. whie you checking for pdf size and get it over size or want to show message.
Ajay2707
Contributor
4421 Points
856 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 11:05 AM|LINK
hi Shivanand,
check this .
http://www.velocityreviews.com/forums/t94976-asp-net-message-box.html
shivanand G ...
Participant
1763 Points
534 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 11:51 AM|LINK
i checked ur code... that woking fine but i want to disply all the message one bye one while executing.. ..?
ur code is showing final checked condtion message.... i want to show all the message...... Help Me plz
if(condition)
{
labtext="mag here" fitst time it shoud show check of the file
if(condition)
{
labtext="mag here" 3ndtime it shoud show check of the file
if(condition)
{
labtext="mag here" 2ndtime it shoud show check of the file
}
else
{
labtext="mag here" 3ndtime it shoud show check of the file
}
}
else
{
labtext="mag here" 2ndtime it shoud show check of the file
}
}
shivanand.G.N (shivu.betta@gmail.com)
softvishu
Member
460 Points
120 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 07:50 PM|LINK
Got nice workaround.
What you do , on upload call function which will do ajax call like this (using jquery here).
$.ajax({ type: "POST", contentType: "application/json; charset=utf-8", url: "Index.aspx/GetOrdersForApproving", data: "{ }", // send an empty object for calls with no parameters dataType: "json", success: function (msg) { // Notice that msg.d is used to retrieve the result object }, failure: function (msg) { // Notice that msg.d is used to retrieve the result object } });__________________________________________________
ARMY: Reason to PROUD
Thanks,
Vishal Sharma
MahadTECH
Star
8976 Points
1659 Posts
Re: how to show message to client on server side operation?
Aug 03, 2012 09:05 PM|LINK
This is an example
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <!-- Here your Upload Control.. --> <asp:FileUpload id="FileUploadControl" runat="server" /> <asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" /> </ContentTemplate> </asp:UpdatePanel>Now, your Code should be like this..
protected void UploadButton_Click(object sender, EventArgs e) { if(FileUploadControl.HasFile) { try { CheckingSizeLabel.Visible = true; // Your Code for Checking Size... if ( Checking size condition true) { CheckingSizeLabel.Text = "Perfect Size!"; string filename = Path.GetFileName(FileUploadControl.FileName); CheckLandScapeLabel.Visible = true; CheckLandScapeLabel.Text = "Please Wait! Checking LandScape Portrait Resolution!"; // Your Code for Checking LandScape.. if ( Landscape condition True) { CheckLandScapeLabel.Text = "Checked! Resolution!"; FileUploadControl.SaveAs(Server.MapPath("~/") + filename); StatusLabel.Text = "Upload status: File uploaded!"; } } } catch(Exception ex) { StatusLabel.Text = "Upload status: The file could not be uploaded. The following error occured: " + ex.Message; } } }I didnt check this Code but this should work after some changes.. Its just Example hope it will help you!
Good Luck` I wish, these will help you! and soon you will resolve your issue...
Mahad Bin Mukhtar
Remember to Mark the replies as Answers
The easiest day was 'yesterday'.
MCP, MCSD
For .NET TECH Blog
softvishu
Member
460 Points
120 Posts
Re: how to show message to client on server side operation?
Aug 04, 2012 03:29 AM|LINK
__________________________________________________
ARMY: Reason to PROUD
Thanks,
Vishal Sharma
softvishu
Member
460 Points
120 Posts
Re: how to show message to client on server side operation?
Aug 10, 2012 05:03 PM|LINK
Dude ultimately what those update progress controls are doing in background is the thing i mentioned , nested ajax calls , if you implement that way it will be much faster.
__________________________________________________
ARMY: Reason to PROUD
Thanks,
Vishal Sharma