Using selection in WebForms.

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.
Fredy992Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bonfire89Commented:
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
Jojo1771Commented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Fredy992Author Commented:
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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Fredy992Author Commented:
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
Jojo1771Commented:
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
Fredy992Author Commented:
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
Fredy992Author Commented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.