How can I cause a postback in code?

D

dee

Hi
How can I cause a postback in code, e.g., without clicking on a button?
Thanks.
Dee
 
Y

Yunus Emre ALPÖZEN [MCAD.NET]

Surely it is possible but my advice u to use a link button set
style="display:none" and use javascript (click method) to raise click
event....
 
B

Brock Allen

Well, it's not quite that simple. You use this method to get a block of javascript
and then you have to attach it somewhere in the rendered HTML (typically
in some client side javascript event). Once the client side event fires,
then it will execute this javascript which triggers the postback.
 
Y

Yunus Emre ALPÖZEN [MCAD.NET]

Microsoft .NET Framework works at server side.
Javascript works on client side.

You should use javascript to submit form. For instance,
<a id="s">a</a>

at javascript code,

s.click()


--

Thanks,
Yunus Emre ALPÖZEN
BSc, MCAD.NET
 
T

TJS

I love the way .net has made things so easy


Brock Allen said:
Well, it's not quite that simple. You use this method to get a block of
javascript and then you have to attach it somewhere in the rendered HTML
(typically in some client side javascript event). Once the client side
event fires, then it will execute this javascript which triggers the
postback.
 
Joined
Mar 3, 2009
Messages
1
Reaction score
0
I would like to ask the same question.

I call a class called OpenPopUp:

OpenPopUp(ddlName, "Select_A_Name.aspx", 250, 250)

and this procedure is:

Public Shared Sub OpenPopUp(ByVal opener As System.Web.UI.WebControls.WebControl, ByVal PagePath As String, ByVal width As Integer, ByVal height As Integer)
' Pop up with controlable window attributes.

Dim clientScript As String
Dim windowAttribs As String = ""

'Building Client side window attributes with width and height.
'Also the the window will be positioned to the middle of the screen
windowAttribs = windowAttribs & "width=" & width & "px,"
windowAttribs = windowAttribs & "height=" & height & "px,"
windowAttribs = windowAttribs & "left=((screen.width - " & width & " )/ 2),"
windowAttribs = windowAttribs & "top= ((screen.height - " & height & ")/ 2),"
windowAttribs = windowAttribs & "status=yes, "
windowAttribs = windowAttribs & "scrollbars=yes, "
windowAttribs = windowAttribs & "toolbar=no, "
windowAttribs = windowAttribs & "location=no, "
windowAttribs = windowAttribs & "menubar=no"

'Building the client script - window.open, with additional parameters
clientScript = "window.open("
clientScript = clientScript & "'" & PagePath & "' , null,"
clientScript = clientScript & "'" & windowAttribs & "'"
clientScript = clientScript & ");"


'register the script to the clientside click event of 'opener' control
opener.Attributes.Add("onClick", clientScript)

End Sub


The browser does not popup this new window until the next post back.

If there is code that could cause a postback, I can possible place it
in my Page_Load event to cause this popup.

Is there code or way to cause a Postback in code?


Thank You'all ahead of time.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top