CodeVerge.Net Beta


   Item Entry   Register  Login  
Microsoft News
Asp.Net Forums
IBM Software
Borland Forums
Adobe Forums
Novell Forums




Can Reply:  No Members Can Edit: No Online: Yes
Zone: > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke Tags:
Item Type: Date Entered: 2/21/2005 3:13:37 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
9.00
XPoints: N/A Replies: 5 Views: 2912 Favorited: 0 Favorite
6 Items, 1 Pages 1 |< << Go >> >|
"toadface" <>
NewsGroup User
Do postback from codebehind2/21/2005 3:13:37 PM

1

How can I force a postback from code?
"cniknet" <>
NewsGroup User
Re: Do postback from codebehind2/21/2005 3:22:47 PM

0

Hmmm...interesting question. Can you share any more information on what you are trying to do?

If you are trying to force a postback from client-side code, it's as simple as calling the clikc() event on the link/button/image from Javascript.
example: document.getElementById("<%= CONTROLNAME.ClientID %>").click();

On the server-side, you can call the postback eventhandler directly.

Nik





Nik Kalyani
Speerio, Inc.

[DotNetNuke and ASP.Net solutions here]
"toadface" <>
NewsGroup User
Re: Do postback from codebehind2/21/2005 3:34:25 PM

0

Here's what I need.......

The user enters credit card into then clicks a "submit" button on a form to submit their payment.

Next, I do a Redirect to another page that displays the "Please wait" message, so the user doesn't keep "clicking" the submit button.

This page then needs to submit the payment to the gateway for processing.

When the payment is processed an approved, declined, or error page page is then displayed.


If I put the submit to gateway code in the page load sub, it doesn't display the message until after the payment is finished processing. So, if I do some thing like the following it should work:


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
LoadPaymentToProcess()
DoThePostBack '<<<<<<<<<<<<<<
Else
SendPaymentToGateway
End IF
End Sub


So, how can I force a postback?
"cniknet" <>
NewsGroup User
Re: Do postback from codebehind2/21/2005 5:00:14 PM

0

Thanks for the additional info. It is still unclear why you need a PostBack in code-behind since the purpose of a PostBack is to submit a form for processing to your code. If you already have access to the form data, couldn't you just do the processing right there. Maybe I just need some more caffeine. ;-)

Here's a technique I use for communicating information to the user while a postback that is expected to take long is being processed:

A) Attach a Javascript onClick() event to the submit button. The button does three things:

1) Disable the button so the user cannot click on it again by setting the enabled property of the button to false.

2) Use window.open to display an HTML page with an animated graphic (a clock, progress bar or something similar)

3) Call document.forms[0].submit() to actually submit the form so the postback handler can do its thing.

This process is simple and does not require any redirects. When the page loads, if can close the open window.

If you want to display actual progress, you can even have the image URL of the animated image in the HTML page set to another aspx page which reads a cache value (updated periodically by the long process) and displays a progress bar of the appropriate length. You'll need to have a meta refresh tag on the HTML page set to a couple of seconds so the progress animation works in near real-time.

Sorry, not much help in answering your actual question but hopefully the above technique can be used to create a simpler solution.

Nik

Nik Kalyani
Speerio, Inc.

[DotNetNuke and ASP.Net solutions here]
"toadface" <>
NewsGroup User
Re: Do postback from codebehind2/21/2005 5:11:17 PM

1

Thanks Nik!

Postback may not be the correct thing to do, but I think you have the idea of what I'm trying to do.

I'm still not sure I understand fully how to do this with the script code... can you point me to any examples?

Thanks !
"cniknet" <>
NewsGroup User
Re: Do postback from codebehind2/21/2005 5:52:44 PM

0

OK, let's say your submit button has an ID of "btnSubmit"

In code-behind, you would add the following (C# code...translate for VB.Net):
btnSubmit.Attributes.Add("onClick","return processForm('" + btnSubmit.ClientID + "')");


and, also add the following:
if (YOUR_PROCESSING_ISCOMPLETE)

this.RegisterStartupScript("Completed","<script language=\"Javascript\">var processingComplete=true;</script>");


In you ascx script file, you would add the following:
<script language="Javascript">

function processForm(buttonId)
{
var btnSubmit = document.getElementById(buttonId);
btnSubmit.enabled = false;

window.open("desktopmodules/yourmodule/processing.htm");
// processing.htm should have meta refresh to reload periodically
// when loading, have Javascript code to check for existence of
// window.opener.processingComplete. If set to true, it indicates
// that the window can close itself with window.close()

document.forms[0].submit();
return(false);
}


I have not tested this code (just typed it in here directly, so apologies in advance for any typos).

Nik



Nik Kalyani
Speerio, Inc.

[DotNetNuke and ASP.Net solutions here]
6 Items, 1 Pages 1 |< << Go >> >|


Free Download:













server error in '/' application......help

collapse/expand

issue if email attachment is above 100 kb (asp.net)

i can't log to asp.net enterprise manager

handle potential null's when databinding to asp:label?

getting into all of this

embedding images in mail sent via smtpmail.smtpserver

how convert the string to the datetime?

just loaded and home page is odd

conditional setting of gridview options

email priority marking

problem with validating the login page using radio buttons with database.

sql error

beta 2 availability

server setup and use

global.asax and root namespace

need guidance for sample applications pls help

navigaturl not showing up in the intellisense?

disabling some of the static links in sitemap

aspx runtime error

loop through linq

field not found

source code

file icon image

server error in '/' application

db design

cross browser compatible image rollover cursor

aspx page : asp controls missing

visual studio.net hosted experience

search accordin to date

need help with exceptions

calender control

how can i select only 50 values in listbox

trouble with read method in oledbdatareader object

.netframework2.0 problems

where can i download the asp 2.0 beta?

dynamically filling and array with text box values

call vb script from asp.net application

problem in uploading to ftp with the file size around 5mb

bc30002 and datatableadapter

a simple question?

code stopped working

how can we skip some steps in wizard control

server control not installed

object reference not set to an instance of an object

how do i upload pictures to an access database

runtime error when veiwing output

reqularexpression: only numbers and spaces allowed

help wanted

server error in '/' application

   
  Privacy | Contact Us
All Times Are GMT