Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 I can t populate my Input field (located on a firs

Author  Topic 

rtutus
Aged Yak Warrior

522 Posts

Posted - 2006-10-22 : 17:17:00
Pb:I can t populate my Input field (located on a first page) from a calendar pop-up page (which is my 2nd page) when my inout field is in a runat=server form

Hi, I needed a basic popup calendar in order to select a date to populate my input field in the page main.aspx. But the code works for me only when the input field is in a non Runat=server form. I want to make it work also in a Runat=server form.
Here is the code:
In the calling page main.aspx I put the textbox to be populated from the calendar of the second page calendar.aspx
main.aspx <form id=myNonServerForm name=myNonServerForm>
<input id= "myInput" type="text" name="inpDate1"><A href="javascript:
calendar_window=window.open('calendar.aspx?formname='myInput','calendar_window','width=155,height=205');
calendar_window.focus();
">Calendar</A>
</form>

Here is the calendar.aspx page that hosts the calendar server control called Calendar1:
in that page, there is a literal to close the window like this:
calendar.aspx
<asp:literal id="Literal1" Runat="server"></asp:literal><A href="javascript:this.close()">Close</A>And here is the Calendar1_SelectionChanged handler in code behind to set the textbox of the calling window main.aspx:
private void Calendar1_SelectionChanged(object sender, System.EventArgs e)
{
string strjscript = "<script language='javascript'>";
strjscript += "window.opener.document.getElementById('" + HttpContext.Current.Request.QueryString["formname"] + "')";
strjscript += ".value = '" + Calendar1.SelectedDate.ToString("d") + "';window.close();";
strjscript += "</script" + ">";
this.Literal1.Text=strjscript;
}

If u try it it will work well. But notice that if I use <form ruant=server> the code wo t work anymore.
Can u please explain to me how we can make it work in runat=server form to take full advantage of asp.net
Thank you.
   

- Advertisement -