RegisterClientScriptBlock - URGENT please

M

Mike

Hi,

I have a form with some dynamic controls. I then open a popup calendar and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" + control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the value of that control is still empty. But on the page, the new value is shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 
P

PJ

It would be helpful if you told us what type "control" is.



Hi,

I have a form with some dynamic controls. I then open a popup calendar and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" + control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the value of that control is still empty. But on the page, the new value is shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 
M

Mike

It is a label.


It would be helpful if you told us what type "control" is.



Hi,

I have a form with some dynamic controls. I then open a popup calendar and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" + control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the value of that control is still empty. But on the page, the new value is shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 
D

Dale

Typically, that is caused by assigning the value in your page init or page
load without regard to IsPostBack. So you're re-initializing the label
before you read the value on postback. Try stepping through your code and
see if you find that happening.

Dale


It is a label.


It would be helpful if you told us what type "control" is.



Hi,

I have a form with some dynamic controls. I then open a popup calendar
and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" +
control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the
value of that control is still empty. But on the page, the new value is
shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 
M

Mike

I debugged, but the Page_Load event is not fired.

Does the script below change the element of the document, but not the one of the form? Or are these two elements the same? Sorry, I am new to all these web stuff...

Mike



Typically, that is caused by assigning the value in your page init or page
load without regard to IsPostBack. So you're re-initializing the label
before you read the value on postback. Try stepping through your code and
see if you find that happening.

Dale


It is a label.


It would be helpful if you told us what type "control" is.



Hi,

I have a form with some dynamic controls. I then open a popup calendar
and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" +
control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the
value of that control is still empty. But on the page, the new value is
shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 
S

Saravana [MVP]

Check out this article,
http://www.microsoft.com/india/msdn/articles/PopupCalendarinASP.aspx

--
Saravana
Microsoft MVP - ASP.NET
www.extremeexperts.com




I debugged, but the Page_Load event is not fired.

Does the script below change the element of the document, but not the one of the form? Or are these two elements the same? Sorry, I am new to all these web stuff...

Mike



Typically, that is caused by assigning the value in your page init or page
load without regard to IsPostBack. So you're re-initializing the label
before you read the value on postback. Try stepping through your code and
see if you find that happening.

Dale


It is a label.


It would be helpful if you told us what type "control" is.



Hi,

I have a form with some dynamic controls. I then open a popup calendar
and set the selected date back to the "parent" form using this statement:

string script = "<script>window.opener.document.getElementById('" +
control.Value + "').innerText = '";
script += myCalendar.SelectedDate.ToString("dd/MM/yyyy") + "'";
script += ";self.close()" ;
script += "</script>";
RegisterClientScriptBlock("test", script);

The problem I am having is that when later accessing the control, the
value of that control is still empty. But on the page, the new value is
shown.

Does anyone have any idea on what could be wrong?

Thanks
Mike
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top