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: 2689 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:













validator question

'page not found' within iframe

aspnet_wp and gen 2 heap grow

hide error message next to validated control

tab order and enter key

error: page_preinit has multiple definitions with identical signatures.

customvalidator won't "fire". code just skips over it..

cross page does not work when placed with in a master page.

using panels insteat of pages with no chance to back button on browser

filling the drop down list

dynamic buttons problem

postbackurl and smartnav bug?

changing the print options of excel file

how to get date and time

newbie in need of an htmlinputfile alternative

xml strings...

events in vb.net;asp.net

error:url can't be empty

search engine indexing, url rewrites, meta tags on dynamic pages

control life cycle

application from vb file

problems display images in a datalist

mouse over delete text with textbox in asp.net/c# help needed....

problems with databinding in dropdownlist

dropdownlist

form posting method

value of hidden variable

databind gridview from other form

a question about wizard control

statement to check if object exists

dataset writexml method - xml:space=preserve attribute

add usercontrol programmatically

automatically fill out form fields when checked...

is there something different about anchor tags in asp.net versus straight html?

error using the request object in asp.net using c#

creating an email form in vs2005ee

hi

calendar control

export to excel functionality through ssl(https://)

radiolistview, onselectedindexchanged and oncheckedchanged issues

setting focus within a web control.....

posting data to another page

trouble with button event handling..

server-based timers to execute task periodically

background music in asp.net pages

how to force a selection in a dropdownlist

send mail .net question

web controls are not staying where i want them

textbox requiredfieldvalidator problem

asp.net user control error

   
  Privacy | Contact Us
All Times Are GMT