473,387 Members | 1,757 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Causing postback

D
Hi

In my asp.net application, on click of a button there is some server side code which decides whether a popup window (displayed using showmodaldialog) is to be displayed. If the popup is displayed, on click of OK on the popup, I need some server side code to be executed on the calling page

Could anyone pls tell me how it is possible to execute the server side code on click of ok on the dialog box

Thanks


Nov 18 '05 #1
3 1239
Hi,

Yep, before closing it set its returnValue
window.returnValue = "ok";
close();

on parent/opening page
var res = showModalDialog("BLAH");
if(typeof(res) != "undefined") if(res == "ok" )
document.forms["FORMNAME"].BTNNAME.click();

In this case it will click BTNNAME if returnValue == "ok"

More info
http://msdn.microsoft.com/library/de...ence_entry.asp

--
Best Regards
Vidar Petursson
==============================
Microsoft Scripting MVP
http://www.icysoft.com/
http://www.microsoft.com/technet/scriptcenter

No matter where you go there you are
==============================
"D" <an*******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
Hi,

In my asp.net application, on click of a button there is some server side
code which decides whether a popup window (displayed using
showmodaldialog) is to be displayed. If the popup is displayed, on click
of OK on the popup, I need some server side code to be executed on the
calling page.

Could anyone pls tell me how it is possible to execute the server side
code on click of ok on the dialog box.

Thanks.

D

Nov 18 '05 #2
D
Thanks for the reply.

I am doing what you said, but it gives a javascript error - btnTemp (that's the name of the hidden button on my page for which I want to cause the postback) is null or not an object.

This is my javascript

function ShowWindow(Message, Mode)
{
var RetVal = "";
var strPage = document.getElementById("pathfordialog").value + "?DialogMessage=" + Message + "&DialogMode=" + Mode;
RetVal= window.showModalDialog(strPage ,"Alert","edge: Raised; center: Yes; help: no; resizable: no; status: no; dialogWidth:750px; dialogHeight:250px");
if (RetVal == '1')
{
document.forms["Form1"].btnTemp.click();
}
return;
}

btnTemp is a asp.net button control which is hidden.
I am returming values 0,1,2 etc from my modal dialog based on whether buttons ok, yes, no etc are clicked on that page.

Nov 18 '05 #3
Hi,

Are you sure the btn is there?
View the source of the page to see if its there
and if it is check for typos, JavaScript is case sensitive

if(document.forms["FORMNAME"].BTNNAME)
{

}
else alert("Btn not found");

Set the btn display/visibility:
style="display:none"....
or
style="visibility:hidden"

--
Best Regards
Vidar Petursson
==============================
Microsoft Visual: Scripting MVP 2000-2004
http://www.icysoft.com/
http://www.deus-x.com/ Instant e-commerce
http://www.microsoft.com/technet/scriptcenter/
Playground: http://213.190.104.211/ ( IE 5.5+ only )

No matter where you go there you are
==============================
"D" <an*******@discussions.microsoft.com> wrote in message
news:B5**********************************@microsof t.com...
Thanks for the reply.

I am doing what you said, but it gives a javascript error - btnTemp
(that's the name of the hidden button on my page for which I want to cause
the postback) is null or not an object.

This is my javascript

function ShowWindow(Message, Mode)
{
var RetVal = "";
var strPage = document.getElementById("pathfordialog").value +
"?DialogMessage=" + Message + "&DialogMode=" + Mode;
RetVal= window.showModalDialog(strPage ,"Alert","edge: Raised; center:
Yes; help: no; resizable: no; status: no; dialogWidth:750px;
dialogHeight:250px");
if (RetVal == '1')
{
document.forms["Form1"].btnTemp.click();
}
return;
}

btnTemp is a asp.net button control which is hidden.
I am returming values 0,1,2 etc from my modal dialog based on whether
buttons ok, yes, no etc are clicked on that page.

Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gill Smith | last post by:
In my ASP.Net application when the user hit the enter key and the focus is on the edit box causing the page to postback. How to avoid this ? -Gish
1
by: Louis-Philippe Dumoulin | last post by:
Hi, I have the following problem in asp 1.1. On my web page, when I click on a menu, a postback is generated. On the post back, I create dynamically with LoadControl a WebGrid (from InterSoft)...
6
by: Vear | last post by:
Hi, I have a web page that is in a master page. The user fills in the page and at the bottom I have a link for terms which when they click is causing post back. Here is the code. Is there a way...
2
by: jon | last post by:
Hi This might be an easy one to answer but I have a web form in an ASP.NET 1.1 application with a hand-rolled HTML image button as follows which opens a help guide in a new window: <input...
0
by: John A Grandy | last post by:
For an .aspx page that uses no server-side controls -- instead it generates all of its html and writes it to the page in the overriden render event. How to write logic for the Page_Load() event...
0
by: mrobins | last post by:
I recently migrated my asp.net 1.1 web project to a new web server and whenever my page posts back, I lose the value in several of my fields. I know the problem applies specifically to databound...
2
by: Norm | last post by:
The error that pops up in a JS alert box is: Sys.WebForms.PageRequestManagerParserErrorException: The message from the server could not be parsed. ... "<DOCTYPE ..." I have three update panels...
5
by: =?Utf-8?B?SnVsaWEgQg==?= | last post by:
Hi all I've got a very complex form with loads of text boxes and buttons on it. It's causing me all sorts of problems when users press the enter key and cause a postback. I need to disable...
2
cameokid
by: cameokid | last post by:
Hi, I have a table with some form fields. This table is hidden on load. I display it on click of a button. After i enter values and click button inside this table. It displays the custom...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.