Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Using selection in WebForms.

Posted on 2006-04-05
7
Medium Priority
?
403 Views
Last Modified: 2008-02-20
I have the following problem: I have "WebForm1". In this WebForm I have some TextBoxex, DropDOwnList, and 3 buttons. In one of the TextBox the user needs to type in a codes product. Beside the TextBox I added a Button in which when the user clicks it I want to open another WebForm or something in which will open a DataGrid with the products that the user can select. And when he select the product the code goes into the TextBox and closes the other WebForm or whatever I make. How can I solve this problem ??? I tried using "UserControl" but I had some problem with it. In fact I addded two questions to see if someone could help me but no one didn´t answer. What is the best way of solving this problem ???? If someone help me, I´ll cancel the other question and add transfer to this question.
0
Comment
Question by:Fredy992
  • 4
  • 2
7 Comments
 
LVL 1

Expert Comment

by:bonfire89
ID: 16387517
my best guess would be to upen the pop up, then when the item is selected in the pop up have it re load up the parent page but with a query string with the selection

ie

goto web form1
click somthing casuing popup of webform2
clcik somthing on webform 2, on that click event, redirect("webform.aspx?myData=thingSelected"), and close window
weform2 frefreshes using the querystring to fill in the data

Thats my best gues
0
 
LVL 5

Accepted Solution

by:
Jojo1771 earned 375 total points
ID: 16388796
If I follow you correctly.

You want to fill a textbox of one web form with that of a selection on another web for.

An Example of how to do this:

I did this all in Word, no dev enviorment at this computer. So please check for Case/grammer Errors in the code.

Logic on this.
1)      Lets create a popup from this window
2)      Now lets pass to it the name of our control (Textbox) via the query string
3)      Now on the pop up page lets use javascript to set our controls value



Page with Textbox

Button
<INPUT type="button" value="Pick"  onclick="btnClick('TextBox1', 800, 600);">


JavaScript
  <script language="Javascript" >
function btnClick(){
   var Popup=null;
  settings='width='+ w + ',height='+ h + ',location=no,directories=no,   menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no, dependent=no';

// The syntax of the window.open method is given below:
//open (URL, windowName[, windowFeatures])

        Popup=window.open(ProductList.aspx?Ctrl=' + ctrl, ‘ProductPage’,  settings);
        Popup.focus();
}

    </script>


_________________________________________

ProductList.aspx -Page

  <script language="Javascript" >

        function HaveDVItem(Value) {

//Get TextboxName from the query string by parsing the string 5
//’Ctrl=’ is 5 digits
            ctrl = window.location.search.substr(1).substring(5);
//Set Text box Value by using the textbox name
            thisForm =  window.opener.document.forms[0].elements[ctrl].value = dateValue;
//Close Form
            self.close();

        }

    </script>

Code Behind on Product Page

‘Once you have found the item you want simply use registerclientscript to call the javscript function, passing in the value that you want to assign to the textbox
'Really not sure on syntax here as I don't have intelisense in word, but I think it goes like this.
Me.clientScript.RegisterClientScript(Me.gettype(), “key1”,  HaveDVItem(MyValue), True)

0
 

Author Comment

by:Fredy992
ID: 16394485
The page to show the other windows I made it and it´s working passing the TextBoxe´s name through the URL. But now I can´t get the other window (ProductList.aspx) pass the value of the TextBox in the ProductList.aspx to the first WebForm when the user cliks on the button. The code you posted:

Me.clientScript.RegisterClientScript(Me.gettype(), “key1”,  HaveDVItem(MyValue), True)

Is not working. It´s giving me alot of syntax error
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Fredy992
ID: 16394663
Another question. Why in the "oncLick" ´s button you put:

btnClick('TextBox1', 800, 600)

If in the function you don´t have to pass any parameters ???

function btnClick(){
   var Popup=null;
   ...........
0
 
LVL 5

Expert Comment

by:Jojo1771
ID: 16397022
Woops COde Error

function btnClick(){

Should of read function btnClick(ctrl,w,h){

and

Heres the correct Code Behind

Easier when i have VS

    Dim MyValue As String = "Somthing I want to set"
        Me.ClientScript.RegisterStartupScript(Me.GetType(), "key1", "HaveDVItem(" & MyValue & ")", True)
0
 

Author Comment

by:Fredy992
ID: 16399395
I´m using C# so I changed to:

this.RegisterStartupScript(this.GetType(),"key1","HaveDVItem(" + MyValue + ")",true);

withou the "ClientScript" because it seems not to have this. But now it´s giving me a compile erros saying:

"No overload for method 'RegisterStartupScript' takes '4' arguments"

What´s wrong with my code ????
0
 

Author Comment

by:Fredy992
ID: 16399537
And a last this. How can I change the code:

ctrl = window.location.search.substr(1).substring(5);

To get the right string because I need to pass more than one string. I´m passing for example:

Popup=window.open("ProductList.aspx?Ctrl=" + ctrl + "&TypeCode=C", "Equipamento" ,settings)

So when I get to the other form it can´t find the "Ctrl".
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Integration Management Part 2
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question