Link to home
Start Free TrialLog in
Avatar of rgrimm
rgrimm

asked on

Refresh IFRAME When Calendar Date Changes

I have a web page that contains a calendar control (Cal) and an IFrame (ifCal).  The IFrame displays a page that contains a repeater control (repCalItems), which displays appointments for the selected date. If you select a date in the calendar control, I want the appointments for the selected date to display in the repeater within the IFrame.

I have set up the IFrame in the VB.NET codebehind with the following:

   Protected WithEvents ifCal As System.Web.UI.HtmlControls.HtmlGenericControl

When I click a date on the Calendar control it calls this sub:

Private Sub Cal_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cal.SelectionChanged
      Dim strTransferTo As String

      strTransferTo = "../Calendar/CalItems.aspx?Date=" & Cal.SelectedDate.ToShortDateString
      ifCal.Attributes().Item("src") = strTransferTo

   End Sub

When I run my form I get the following error:

     Object reference not set to an instance of an object.

It fails on this line of code:

      ifCal.Attributes().Item("src") = strTransferTo


What am I doing wrong?
ASKER CERTIFIED SOLUTION
Avatar of tusharashah
tusharashah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgrimm
rgrimm

ASKER

I am not understanding something. I copy/pasted your code into my program. It runs, but it doesn't do anything, other than append the Javascript to the bottom of the web page containing the calendar. It isn't passing anything to the IFrame.
Do you have ID attribute setup in your IFRAME? You need to setup ID of your Frame and replace it with frameid in code:

document.getElementById('frameid')

    <iframe id="frameid" width=300 height=300>
   
    </iframe>

-tushar
Avatar of rgrimm

ASKER

Found the problem. I forgot to change your 'frameid' to the name of my frame. Works great!

Thanks!

rick