Hi Varun
Following a couple of solutions.
#1
Given that you open webform2 using client side javasript contained in
webform1. Both pages must be open at the same time.
Place a HTML button on webform1. Set the onclick event like this:
<INPUT id="Button1" style="Z-INDEX: 112; LEFT: 352px; WIDTH: 80px;
POSITION: absolute; TOP: 112px; HEIGHT: 24px"
onclick="window.open('webform2.aspx','_blank')" type="button"
value="Webform 2" name="Button1" runat="server">
Note: You don't need to run it as a server control, I just do it so
I've a convenient way of enabling/disabling the button from within vb
code.
Do the same for webform2 using:
<INPUT id="Button2" style="Z-INDEX: 112; LEFT: 352px; WIDTH: 80px;
POSITION: absolute; TOP: 112px; HEIGHT: 24px" onclick="update()"
type="button" value="Update Webform 1" name="Button2" runat="server">
Place this javascript shortly before the </Head> closing tag of
webform2:
<script language="javascript">
<!--
// Function Update - Updates Opener Page With Text Field Value
function update() {
opener.form1.textbox1.value = textbox2.value
parent.window.close();
}
//-->
</script>
</HEAD>
Place a HTML textbox control on both, webform1 and webform2, setting
the id for the one on webform1 to textbox1 the one on webform2 to
textbox2. Run them as server controls, so you can access the .text
property from within VB.
Now, if run it and everything is right, clicking on button1 will open
webform2.aspx in a new window. Type some text into textbox2 and click
button2.
The textbox in webform1 is updated and webform2 closes.
#2
Another suggestion, using webform controls except for button2:
Save the textbox2.text value in a session variable (MyValue). Set the
onclick event for button2 as shown above but use this javascript:
<script language="javascript">
<!--
// Function Update - Updates webform1 With Text Field Value
function update() {
window.opener.location.href = 'keymain.aspx';
}
//-->
</script>
</HEAD>
Set the Page_OnLoad event for webform1 to:
Textbox1.Text = CStr(Session("MyValue"))
When clicking on button2, webform1 refreshes, getting the textbox
value from the session. Again, both pages must be open in this
scenario but you don't need to have webform1 called by webform2.
#3 Without java script
If you don't want to immediately refresh textbox1 as soon as you click
button2, simply use the same scenario as in #2 but a
Server.Transfer("webform1.aspx") for the button2 click event directly
in VB. This way webform1 doesn't need to be open in the background.
Hope this helps!