0

I inserted the gif image in securetrans.aspx page and wrote the payment gateway request code in securetrans.aspx.cs page pageload, here the problem is the loading image is not at all showing up through out the request and the page is empty till the response comes. I cant get it through many searches, hope some one helps me out..

Thanks in advance...

my securetrans.aspx.cs code is

protected void Page_Load(object sender, EventArgs e)
{

string Url = "https://paymentpagetosendrequest";
        string Method = "post";
        string FormName = "form1";


NameValueCollection FormFields = new NameValueCollection();
 FormFields.Add("account_id", "5880");
        FormFields.Add("reference_no", Session["UserID"].ToString());
        FormFields.Add("amount", Session["Amount"].ToString());


FormFields.Add("return_url", "http://responsepage");
 for (int i = 0; i < FormFields.Keys.Count; i++)
        {
            Response.Write(string.Format("<input name=\"{0}\" type=\"hidden\" value=\"{1}\">", FormFields.Keys[i], FormFields[FormFields.Keys[i]]));
        }
}

and secruretrans.aspx

Loading... Please Wait!!!

You will be Redirected to Secured Transaction Page....

(Please don't press back or refresh button.)


<asp:Image runat="server" ImageUrl="images/Loader.gif" ID="img" AlternateText="Loader" />
MethodMan
  • 18,625
  • 6
  • 34
  • 52

3 Answers3

0

Unless you specifically code it to send response within you pageload before some other code (which will cause another problem that you can't add more things to the response for display) as while you code running the browser got nothing can show up, I think you are trying to do something like display a processing img, I'd say suggest you go with some jQuery plugin like blockUI: http://www.malsup.com/jquery/block/

EDIT:

OK I assume user come to your page via a redirect or something so you don't have any button, then I suggest you add the blockUI on that page before send redirect so user can see the loading message. Or you can build a third page, and user will be redirect to that page first, that page got nothing except the loading message and a html head meta http-equiv="REFRESH" that actually lead them to your page, so that they can see loading image. Check something here: http://www.instant-web-site-tools.com/html-redirect.html

Simon Wang
  • 2,843
  • 1
  • 16
  • 32
  • yes... ! I will try to make it.. but here I have mentioned the code also, check and suggest me with more options please....Thank you very much – Deepika Ramani Dec 11 '12 at 06:12
0

You need to use some JS for this because controls in the page renders only after page has been loaded

Try DEMO here and CODE here.

function ShowProgress() {
    setTimeout(function () {
        var modal = $('<div />');
        modal.addClass("modal");
        $('body').append(modal);
        var loading = $(".loading");
        loading.show();
        var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
        var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
        loading.css({ top: top, left: left });
    }, 200);
}
$('form').live("submit", function () {
    ShowProgress();
});
sajanyamaha
  • 3,119
  • 2
  • 26
  • 44
  • Sorry,. But I dont have any submit button or any event other than the page load, so can you please mention how could I use it with pageload.. thanq.. – Deepika Ramani Dec 11 '12 at 06:28
  • try the DEMO link above,it works on page loaad,it dont have a button – sajanyamaha Dec 11 '12 at 06:30
  • there itself in page load u mentioned button submit id, is that means till the button click??? for me its not required.. – Deepika Ramani Dec 11 '12 at 06:59
  • ok,place a buton in your page with this Id and just hide it,this is actualy wiring up button click event,and do all things exactly as said there,including the button JS – sajanyamaha Dec 11 '12 at 07:03
0

You can put the below code in page load event:

 string script = "$(document).ready(function () { $('[id*=form1]').load(); });";
 ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);

where "form1" is the name of the form tag.

Andrew Mortimer
  • 2,380
  • 7
  • 31
  • 33