开发者

javascript calendar pop up not working

开发者 https://www.devze.com 2023-01-24 05:13 出处:网络
I am trying get Javascript popup calendar control to work which doesnt work.I am getting an error \"Microsoft JScript runtime error: \'window.opener.document.forms(...).control\' is null o开发者_开发

I am trying get Javascript popup calendar control to work which doesnt work. I am getting

an error "Microsoft JScript runtime error: 'window.opener.document.forms(...).control' is null o开发者_开发百科r not an object". Here is my event,

protected void Change_Date(System.Object sender, System.EventArgs e)
{
    string strScript = "<script>window.opener.document.forms(0)." + control.ClientID + ".value = '";
        strScript += calDate.SelectedDate.ToString("MM/dd/yyyy");
        strScript += "';self.close()";
        strScript += "</" + "script>";

        ClientScript.RegisterClientScriptBlock(this.GetType(), "Startup", strScript);
}

It displays the calendar fine but when I click on the date, I am getting the error and the date is inserted into the textbox.


wrong brackets:

.document.forms(0)

should be

.document.forms[0]


Do you actually have an element with id "control" in your form?

Your line here is wrong:

    string strScript = "<script>window.opener.document.forms(0)." + control.ClientID + ".value = '";

As has already been pointed out it should be forms[0] instead of forms(0) but then it is searching for an element in the form with id "control"

Looks like your control.ClientID value was returned wrong, the easiest way to find out what it should be is to look at the actual HTML of the form and find the id of the control you're looking for, and test your method with that, then figure out why control.ClientID isn't returning an existing value.

0

精彩评论

暂无评论...
验证码 换一张
取 消