الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

closing a pop up window

مغلق
بدأه ماجدة سليمان في 9 أكتوبر 2005 · 5 رد · 689 مشاهدة · في ASP.NET
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

salam alekom all,,

i need some help on my case :

i have a page1.aspx that contain a data grid (editable one) , i create a template column on this data grid as a link button field , the user should enter a code in the data grid field if he forget the code no he press on the link button that open a pop up window which let the user search on the desired code ,once he found it he close the pop up window & the return value must be filled in the field of the data grid ...

my problem was on how to return a value from the pop up window to page1 without reload the setting of page 1 as it's first time so i can't loose my page data , i create a session & it pass correctly but when i close the pop up window i need to redirect the response to the main page page1.aspx & automatically filled the passing session value to the datagrid field without loosing my first page loading data .. :wacko:

thanks in advance

#2

Salam Alaikom

I have had a similar problem like this... and this is how I solved it:

First of all, you said it is inside the editable column (edittemplatecolumn) inside the datagrid.... I would say, you would know from this what's the row ID.... index ID i mean....

When a user click on the Link Button, basically you post back to the server - am I right - and thus you just need to know which row you are working on ...

You will need to pass the ClientID of the control you want to be filled with the value selected after closing your popup window.... in a querystring to the popup window

YourWindow.aspx?ControlID=YourControl.ClientID

Inside a datagrid, every control - even if it is given the same name in design mode - will be rendered with a unique ID on the client - Browser.

Now, in the popup window after the user will select - search for a value there - just before you submit and close the window and pass the value to the parent window... do something like this:

Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
        If Page.IsValid Then
            SetValue(YourControlClientID, SearchResultFound)
        End If
    End Sub

Private Sub SetValue(ByVal field As String, ByVal selValue As String)
        Dim script As String
        Dim param0 As String = "window.opener.document.Form1."
        Dim param1 As String

        script = "<script language=javascript>              "
                 param1 += param0 & field  & ".value='" & selValue & "';"
        script += "setSelectedValues(""" & param1 & """);         "
        script += "</script>                                "

        If (Not Me.IsClientScriptBlockRegistered("sctDate")) Then
            Me.RegisterClientScriptBlock("sctDate", script)
        End If
    End Sub

The setSelectedValues function is a javascript function in the head of the ASPX file... and it will take care of evaluating the string back to the datagrid - parent page - and closes the popup window

<script language=javascript>
function setSelectedValues(param)
   {
	eval(param);
	self.close()
   }
        </script>

Good luck و وفقك الله

تم تعديل هذه المشاركة بواسطة alharethi في 9 أكتوبر 2005 في 20:42

Quran_Signature.jpg
#3

salam alekom ,,,

thanks alot for ur response and can i clarify some notes from u , i wonna understans this part of ur solution :

note1 :

when i click on the linbutton ( that i create on the data grid to open the popup window for search help result ) u said that to pass in a querystring to the popup window

YourWindow.aspx?controlid=Yourcontrol.clientid ,,,right !!

do u mean Your control the datagrid name ..

note 2:

in the pop up window javascript code

function setselectedvalues(param)

{

eval(param);

self.close ;

}

what the eval do ??

and am very thankful to u all , inshallah it will work with me well with ur help :D

#4

السلام عليكم

اقتباس
when i click on the linbutton ( that i create on the data grid to open the popup window for search help result ) u said that to pass in a querystring to the popup window

YourWindow.aspx?controlid=Yourcontrol.clientid ,,,right !!

do u mean Your control the datagrid name

I mean by the control, the textbox which should be filled by a value selected from the popup window. Meaning, in a datagrid, suppose you have 3 columns, first one is ID, second is textbox having the value returned from the popup window adn third column is the link button...

Now, when the page is rendered, every textbox - here, it is your control in every second column - will be indentified with a unique ID to the clients browser, what you need to pass is this controls client ID.... using the same query in the above quote.

in the pop up window javascript code 
function setselectedvalues(param)
{
eval(param);
self.close;
}

what the eval do ??

If you look at the other funtion which is called from the Submit subroutine, you will see I am passing a selected value - in the popup window - and a control ID... the selected value is what the user has selected in the popup window and the control ID is the control client's ID which we passed previously in a QueryString.... since the new popup window was opened from the parent - main menu, you can access the parents controls and access/change their values - if possible - by using:

window.opener.document.Form1.ControlClientID.Value

now, at this point, After you click the submit button, you will pass these values - mentioned in my previous paragraph in this reply - to SetValue subroutine - which I made it little fancy just assuming you might have more controls or you even can get ride off it and make everything within the Submit Sub - which will process the values and build a string like:

window.opener.document.Form1.ControlClientID.Value = User's Selected ID

This will be passed to the javascript code inside our ASPX file - on top within the header or wherever u like to put it inside the ASPX file - to our function called: setselectedvalues

I used the Eval expression, because it will assign the values selected back to the parent window and parent form.... and then closes the window. The reason I did it like this is that I tried to build the javascript code inside the SetValue sub routine, but it did not work, so I used this function inside the ASPX file....

Eval javascript function takes a parameter and it will execute it, so here in this example, it will assign the value from the popup window and assign it back to our control in the second column inside the datagrid in the parent window...

I hope this will help.... Salam

Quran_Signature.jpg
#5

salam alekom

well it was very helpful thanks alotttttttttttt ,, and i worked on it it works succesfully just the way i want it ,, really am very thankful

may allah bless u all

:D

#6

salam

glad to be of help...

salam

Quran_Signature.jpg

هذا الموضوع مغلق.

مواضيع مشابهة