473,387 Members | 1,423 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.

Forcing postback on a web dialogs opening window

Ok, here is my problem.

I have an aspx page that displays a databound datagrid and in one of
the datagrid column headers I have an image that when clicked opens up
a modal web dialog (another aspx page).
From this dialog I want the users to be able to select a filter item

from a databound combobox and click on the apply button on the web
dialog that will then disappear and the filtered data will be displayed
on my datagrid.

Now here is the problem: How can I force a postback on the original
aspx page containing the datagrid so that only the filtered data is
displayed? Basically I want to pass back the selected cobobox item from
the web dialog to the calling window and then use that data to filter
my dataset and rebind to the datagrid.

I've thought about using hidden input fields on the datagrid page and
populating them when the user clicks the apply button on the web
dialog. But how do I then fire a postback to rebind my datagrid? Is
there a way to fire the postback on the datagrid page when the user
clicks the apply button on the web dialog page? The way I'm going about
it just now involves mainly client side java script but I am sure there
must be a way to do this server side?

Anyway, if anyone has any pointers I would be very grateful.

Thanks,

Vincent

Nov 19 '05 #1
6 2416
Add a server-side Button control to the main page, set its Visible to false
and generate a javascript call with
Page.GetPostBackEventReference(the-button-as-argument-here).

That'll return you a __doPostBack call which is able to cause button click
effect when it is called at client-side. So extend the idea and create your
own js method and append the js call generated in previous step to it. So
that you can call it cross window from the popup and calling it causes the
postback.

So in essence effect is that when you call that from popup window
(opener.yourmethodname() if main page is the opener window and
yourmethodname() function has the call to __doPostback with the dummy button
as argument) it is as if __doPostBack is called for the hidden button and
you can actually run sensible logic in the main window and control that from
the popup.

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #2
Here is also a blog post and a sample covering this technique
http://blogs.aspadvice.com/joteke/ar...6/15/4063.aspx

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
Nov 19 '05 #3
I have to do this so often, I wrote a set of server controls to help. I've
uploaded them to GotDotNet, so in a few days you should be able to find them
there.

Assuming that you have added a client side handler for the click event to a
normal control (which is what I do in the library), the postback will occur
based on whether you return true or false from the onclick event. If you
return false, it will not postback. If you return true, it will postback.
An example:

'Building Client side window attributes with width and height.
'the the window will be positioned to the middle of the screen
windowAttribs = "dialogHeight:" & _dialogHeight & "px;" & _
"dialogWidth:" & _dialogWidth & "px;" & _
"left:'+((screen.width -" & _dialogWidth & ") /
2)+';" & _
"top:'+ (screen.height - " & _dialogHeight & ")
/ 2+';" & _
"edge:Sunken; status:0;" & _
"resizable:0;Help:No;"

'Building the client script- window.open, with additional
parameters
'having return true; at the end of this line is what allows the
web control's
'server side click event still fire
clientScript = "rsc_getObj(""" & Me.UniqueID &
"_DIALOGRETURNVALUE" & """).value=window.showModalDialog(""" & _pagePath &
""",""" & _windowName & """,""" & windowAttribs & """);if(rsc_getObj(""" &
Me.UniqueID & "_DIALOGRETURNVALUE" & """).value!=""0"" & rsc_getObj(""" &
Me.UniqueID & "_DIALOGRETURNVALUE" & """).value!=""undefined""){return
true;}else{return false;}"

"SkeanDu" wrote:
Ok, here is my problem.

I have an aspx page that displays a databound datagrid and in one of
the datagrid column headers I have an image that when clicked opens up
a modal web dialog (another aspx page).
From this dialog I want the users to be able to select a filter item

from a databound combobox and click on the apply button on the web
dialog that will then disappear and the filtered data will be displayed
on my datagrid.

Now here is the problem: How can I force a postback on the original
aspx page containing the datagrid so that only the filtered data is
displayed? Basically I want to pass back the selected cobobox item from
the web dialog to the calling window and then use that data to filter
my dataset and rebind to the datagrid.

I've thought about using hidden input fields on the datagrid page and
populating them when the user clicks the apply button on the web
dialog. But how do I then fire a postback to rebind my datagrid? Is
there a way to fire the postback on the datagrid page when the user
clicks the apply button on the web dialog page? The way I'm going about
it just now involves mainly client side java script but I am sure there
must be a way to do this server side?

Anyway, if anyone has any pointers I would be very grateful.

Thanks,

Vincent

Nov 19 '05 #4
Thanks Teemu,

I followed the blog post and finally got the postback to happen from
the main page. Only problem is it doesn't complete the postback until
the modal web dialog is manually closed. I've tried closing it
programatically with 'self.close' and 'window.close' before and after
the the call to the doPastback function on the main page but it just
doesn't seem to want to close. When I break in the main page just
before the doPostBack is called I seem to have no visibility of the web
dialog although it is still displayed. I'm sure there is a simple
solution but I just can't see it!!

Nov 19 '05 #5
John where are your server controls located? I couldn't see them on
GotDotNet.

Nov 19 '05 #6
Ah,

you use those *real* :-) modal dialogs (window.showModalDialog etc), mine is
using just popup (which you can try to force to be on top though there's no
bullet-proof solution to that). I suppose that with them you first have to
complete the dialog before postback can happen (execution goes back to the
window that opened the dialog)

Teemu
Nov 19 '05 #7

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

Similar topics

2
by: Sean Burns | last post by:
Hello, does anybody know how to open a dialog window in opera? I use window.showModalDialog(....) for IE but Opera says "Expression did not evaluate to a function object: window.showModalDialog"...
3
by: Rod | last post by:
I have an asp.net application where some of the interaction with the user is through modal dialog windows. This works very well except for the annoying fact that the dialog window always returns...
2
by: KathyB | last post by:
Hi, In the pageload of my aspx file I have the following (in both not in postback and is postback)... btnList.Attributes.Add("onclick", "window.open('Scanned.aspx', 'Serial Numbers',...
3
by: majid | last post by:
When i show a webform as a dialogbox using showModalDialog script any postback event in dialogbox cause a new window pops up . How can i control the postback?
2
by: Ashish | last post by:
Hi All, I have a server runnable textbox control. I also have a server side button object but I hook up javascript to it to show a modal dialog. Upon return it places the value in the textbox...
0
by: MikeB | last post by:
This post is not about postbacks opening a new window from a showModalDialog window. I am using a modal dialog to populate a textbox in my form. When the form is submitted the code behind logic...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: Henry Johnson | last post by:
I'm currently opening an aspx page (myModalASPX) as a dialog box from client-side script using window.showModalDialog(blah blah blah). The dialog opens as expected. Now I'm adding functionality...
3
by: Abid Ali | last post by:
Dear All I want to call dopostback of parent window from child window. Scenerio I am opening window from a page, and i have datatable in session which is updating at parent window and at...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.