Load Text box of one web form with selected list item of list box of another web form


one help please

Problem is
i have two web forms
 1.  ForiegnkeyTest.aspx
 2. foroginkeytable.aspx

 

step 1 1 ForiegnkeyTest.aspx one web form

<head runat="server">
<script language="javascript" type="text/javascript">
   function popWin()
   {
         var confirmWin = null;
      confirmWin = window.open('foroginkeytable.aspx','anycontent',   'width=455,height=435,status');
   }
  </script>

    <        &nbsp;<asp:TextBox ID="txtaeropuerto" runat="server" CssClass="txtBox" MaxLength="3" Width="85px"></asp:TextBox></div>
        <br />
        <br />
        <input type="button" onClick="popWin()" value="Open Window">
  


step2 . foroginkeytable.aspx ( tiena una listbox cargando sobre base de datos

<div>
        <asp:DropDownList ID="txtciudad" runat="server" CssClass="dropdown" DataSourceID="SqlDataSourceCIUDAD"
            DataTextField="CIUDAD" DataValueField="CIUDAD" Width="90px">
        </asp:DropDownList>
        <asp:SqlDataSource ID="SqlDataSourceCIUDAD" runat="server" ConnectionString="<%$ ConnectionStrings:PortalPaxNTv10 %>"
            SelectCommand="SELECT [CIUDAD] FROM [PP_CIUDAD]"></asp:SqlDataSource>
        <input id="Button1" type="button" value="loadtextbox" />
    </div>
    </form>


NOW question is ......

 

when i select the list  item of listbox of web from  foroginkeytable.aspx ,and click buuton accept Button1 , the selcted item
should be get loaded in textbox of txtaeropuerto  of another web form  ForiegnkeyTest.aspx, and web form foroginkeytable.aspx get closed
automatically after this event

 so can you send me any code logic or web refrence or any hint   to this problem

rest is fine
waiting

warm regards
virender singh

 




Virender singh
MCA, CCNA
System Analyst
virender.singh@panel.es
unisys.vsingh@iberia.es
Virender.Singh@es.unisys.com
VISION IS FUTURE
Madrid( Spain)



-1
dearviren
7/10/2007 8:56:41 AM
asp.net.web-forms 93655 articles. 3 followers. Follow

5 Replies
1381 Views

Similar Articles

[PageSpeed] 34

Hi virender,

What I should do is the following. I should work with a SessionVariable.

Ok, so you have your table.aspx (the popup) and the test.aspx ( the opener).

What should all be set:

  • on the opener, you already assign SessionVariable to the textbox-text. But the SessionVariable hasn't been set yet so the text is just empty. (make sure that with the instantiation of the SessionVariable you assigned it an empty string or whatever, just make sure it's not NULL --> to avoid null reference errors)
  • Now you open the popup, this is where your listitem will be selected.
  • Now you have to store the selected item in your sessionVariable. Something like Session("MyCrossPageVar") = item.text (or whatever)
  • Now just one more thing needs to happen: Close the popup, and refresh the opener
  • When the opener is refreshed, the SessionVariable (which has a new value) is assigned again to the textbox and that's how the value came from the popup to the opener
  • To close the popup and refresh the opener, you should execute some javascript on the popup page. The code has to be something like this:
     
    function closePopupAndReloadOpener()
    {
      if (opener && !opener.closed)
      {
        opener.location.reload();
      }
      window.close();
    }
     

Please give it a try!
If you have further questions or remarks I'd like to hear them.

Greetz,
Wim


Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
0
deblendewim
7/10/2007 9:40:52 AM

 u can use window.opener to access the textbox in the parent window to set the value of textbox before closing the window and if id of textbox is dynamically generated send it in the query string to the popup page


Regards,
Hossam El-Deen M. Barakat
Microsoft Certified Technology Specialist(Web, Windows)
Blog: http://HossamElDeen.blogspot.com
2
Hossam_El_Deen
7/10/2007 9:41:34 AM

hello Greetz,
Wim

1. to avoid null error reference i have done this in ForiegnkeyTest c# file

protected void Page_Load(object sender, EventArgs e)

{if( Page.Request.QueryString["IdAeropuerto"]!=null)

txtaeropuerto.Text = Page.Request.QueryString["IdAeropuerto"].ToString();

2.now opened pòpup like this

protected void Button2_Click(object sender, EventArgs e) //// Button2 type run on server

{

Button2.Attributes.Add(
"onclick", "window.open('foroginkeytable.aspx',null,'height=400, width=400,status= no, resizable= no, scrollbars=no, toolbar=no,location=no,menubar=no ');");

}

3.,protected void Button2_Click(object sender, EventArgs e)

{

Response.Redirect(
"foroginkeytable.aspx?IdAeropuerto=" + txtciudad.SelectedValue.ToString(),true);

}

 

4 . now it is not refelcting in txtaeropuerto.Text  of ForiegnkeyTes.aspx file , ??????, there is no error like comilation error

  please clear me last two points of your reply and advise me how to load this  txtaeropuerto.Text  of  ForiegnkeyTest.aspx file

any idea ??????

regards

 

 




Virender singh
MCA, CCNA
System Analyst
virender.singh@panel.es
unisys.vsingh@iberia.es
Virender.Singh@es.unisys.com
VISION IS FUTURE
Madrid( Spain)



1
dearviren
7/10/2007 10:42:58 AM

Hello please tell me code example

how to implement this concept with session varriables, as

txtaeropuerto.Text not geeting suppied value

txtaeropuerto.Text = Page.Request.QueryString["IdAeropuerto"].ToString();

???

by this event

Button1.Attributes.Add("OnClick", "return window.open('foroginkeytable.aspx');");

Response.Redirect("foroginkeytable.aspx?IdAeropuerto=" + txtciudad.SelectedValue.ToString(), true);

as it is op up window???? or some anotjher reason

how to impelement with session variable please advise me

lof thanks in advance for support

regards

 

 




Virender singh
MCA, CCNA
System Analyst
virender.singh@panel.es
unisys.vsingh@iberia.es
Virender.Singh@es.unisys.com
VISION IS FUTURE
Madrid( Spain)



1
dearviren
7/11/2007 8:18:52 AM

Hello i got sucess to achieve with session varriable LOT OF thanks for support Big Smile

public partial class ForiegnkeyTest : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

Page.MaintainScrollPositionOnPostBack = true;

if (Page.Session["IdAeropuerto"]!= null)

txtaeropuerto.Text = Session[
"IdAeropuerto"].ToString();

Session.Remove("IdAeropuerto");

break;

}

 

 

}

 

protected void Button1_Click(object sender, EventArgs e)

{

Button1.Attributes.Add("OnClick", "return window.open('foroginkeytable.aspx');");

}

****************************

foroginkeytable .aspx c#.net source web form ***************

protected void Button2_Click(object sender, EventArgs e)

{

try

{

Session[
"IdAeropuerto"] = txtciudad.SelectedValue.ToString();
Server.Transfer("ForiegnkeyTest.aspx");

 

 }

catch (HttpException exp)

{

 

}

 

}

 NOW its functioning thanks for IDEA Idea

http://www.dotnetbips.com/articles/displayarticledetails.aspx?articleid=79




Virender singh
MCA, CCNA
System Analyst
virender.singh@panel.es
unisys.vsingh@iberia.es
Virender.Singh@es.unisys.com
VISION IS FUTURE
Madrid( Spain)



-1
dearviren
7/11/2007 9:43:59 AM
Reply:

Similar Artilces:

Problem in selecting text in List box Web Form
hi In List box load the data from database. If i am select any Item from list box i am geting selected Indexvalue ="-1" at the same time i am not get the text value. how can i get the selected index text value. Regards, Sabarish. Hi, it sounds to me that you're rebinding your data upon every postback. If you're doing it in code behind place it between if(!Page.IsPostBack) to avoid this. Then you should be able to get a value different than -1 (which means nothing's selected). Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for...

synchronizing chunk of data of one web form for another web form
I'm making a web application. In one web form; i'm taking inputs from user. Now; there is some info given by user in this page which is needed for web form which is going to be displayed next. i want to display that info automatically on that web form so that user doesn't have to re-input that info in this next web form. Info from first page would be inserted into database when user clicks on the submit button. then that next web form would be displayed. and the chunk of info from previous page should be displayed there!!! how can i do this?? cany anybody help?? nobody can help me!! I...

calling a web form from another web form
I would like to know what is the best way to open a web form from another web form. I would like to call it from a button control. Thanks Well, if I've grasped your question right, there are many methods to do that: 1)Response.Redirect > To navigate to another page from code and is equal to clicking a hyperlink. I suggest this as I think it's closer to your question. 2)Server.Transfer > This ends the current web form and begins a new web form. It's usable when you want to pass some variables i.e (Label1.Text) to the next immediate page. It's not safe though and not used to send p...

Web Form embedded in another Web Form
Hi,  I have programmed a Web Form which acts like a scientific calculator. I would like to embedd this calculator in the upper left hand corner of another accounting Web Form. I don't want to host the calculator on the same server as the accounting page. I.e. I want them to have distinct URLs. Classically, I would do this using frames, but is there a better way using ASP? Is there some sort of Panel which can display the webpage at a specific URL which I can just drag onto my accounting Web Form? Thanks,  P1000   Frames are the only way to embed a webform inside ano...

move controls and other tools anywhere around the web form and add datagrid list items to a normal list box
how can i place control and other tools anywhere around the page? for some reason i cannot place and move any of my tools and controls anywhere i want them to be. my web form does not look nice. you know like in ms dreamweaver and vb.net, u can place text box,labels etc anywhere on the form, thats exactly what i want to be able to do. also how can i add items from a datagrid list to a normal list box using a button? the datagrid list is data bound. the examples that i have seen so far shows items that are built into the code and then added to the list but nothing for data binded control. any...

Passing Values from a Web Form to Another Web Form
Hello All! I am trying to pass values from one web form to another web form. I know that there are 3 ways of doing this: queryString, Server.Transfer and Session. I am using the Server.Transfer method. But I am not able to create, in my 2nd web form, an instance of my 1st web form. My 1st Web form is named CallTrack.aspx and my 2nd is named Export.aspx. What I mean is something like this: Public value as CallTrack. I can't create it in my 2nd web form because when the intellisense is displayed, there's no CallTrack in the options. Thanks!   How about using cross-...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

can someone one give me difference between web form and mobile web form and which or where or when i'm using the forms?
thanks Marc Hi Marc, Based on my understanding, you want to know the differences between the ASP.NET web application and ASP.NET mobile web application. If I have misunderstood you, please feel free to let me know. The ASP.NET forms are used to develop the ASP.NET pages for desktop browsers and The ASP.NET mobile forms are used to develop the ASP.NET pages for mobile device browsers. When we create the ASP.NET mobile web forms pages, we can use nearly all the features of ASP.NET. But there are a couple of compatibility issues: Error Handling and Reporting. Tracing. Using Redi...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

how to make one list box(this list box should have selected products) gets filled from another list box (for example this list box has the whole products) by using navigation control
Hello Mate!, I have two list boxes. one should get populated with whole products. and i have another list box in which i have to move some of the products which i like .   The design should be the one below: List Box1   List Box 2 all products   Selected products BMW    >> BMW BENZ     > LEXUS AUDI     <   LEXUS    <<     Could you please suggest me whether i have to use buttons(by which i move items from one list box to another)  ...

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Web Form vs. Web Content Form
If you don't mind, I would like to know what is the difference between those two items, when I go to add a new item I see both of those and I don't know what the difference is.  A content form is for use with a masterpage. A web form is a standalone web page. If you select web content form, you will then have to specify a masterpage for it. and what is a master page used for?  Hi, a master page is used to give a constant look and theme to a site, without having to duplicate code. So basically you can put your header, menu, nav and footer on a master page. Then a...

Include web form inside web form
I tried to include an aspx file in a asp.net web form. However, all the web controls (textbox, button) in the included page are not displayed when called. <Form id="Form1" method="post" runat="server"> <%   Response.writeFile("subPage.aspx"); %> <asp:button id="btnPrev" runat="server" text="Previous"></asp:button> </Form> There are some <asp:textbox> controls in the subPage.aspx file, the file itself works fine, but when it is included in the main page, all the controls are not displayed. Please assist. Thanks   u should u...