Auto postback problem - InfoPath Dev
in

InfoPath Dev

Auto postback problem

Last post 12-01-2008 09:43 PM by qnguyen. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 11-30-2008 08:14 PM

    Auto postback problem

    Hi all,

    I am a newbie in InfoPath dev. I created an InfoPath form (2007) has code in VS2008. In form, I have 2 date pickers and a repeating table. When I choose date, the repeating table show value depending on dates. It runs well when I preview on InfoPath program also can debug on VS 2008. But when I deploy on SharePoint, the repeating table doesn't change immediately after choosing date. It only changes when I save the InfoPath form. The InfoPath form is run with "Display as a Web page" mode.

    Thanks

    q
  • 11-30-2008 08:20 PM In reply to

    • Anuma
    • Top 25 Contributor
      Female
    • Joined on 07-20-2005
    • India
    • Posts 525

    Hello qnguyen,

    Welcome to the Infopath Dev Forums.

    What Code/Conditions you are using to change the Repeating Table?

    Anuma Chinthapalli /
    http://www.GGKTech.com
  • 11-30-2008 08:39 PM In reply to

    Hi,

    Thanks your quick reply. I use "Changed Event" with right click on Date Picker and choose Programming

    Here's my code:

    private double _totalAbsentDays

    {

    get

    {

    return Convert.ToDouble(FormState["_totalAbsentDays"]);

    }

    set

    {

    FormState[
    "_totalAbsentDays"] = value;

    }

    }

    public void InternalStartup()

    {

    EventManager.XmlEvents[
    "/my:myFields/my:fieldStartDate"].Changed += new XmlChangedEventHandler(fieldStartDate_Changed);

    EventManager.XmlEvents["/my:myFields/my:fieldEndDate"].Changed += new XmlChangedEventHandler(fieldEndDate_Changed);

    }

    public void fieldStartDate_Changed(object sender, XmlEventArgs e)

    {

    LeaveDetails();

    }

    public void fieldEndDate_Changed(object sender, XmlEventArgs e)

    {

    LeaveDetails();

    }

    private void LeaveDetails()

    {

    XPathNavigator xPathNavi = MainDataSource.CreateNavigator();

    XPathNavigator details = xPathNavi.SelectSingleNode("/my:myFields/my:grpDetailsDate", NamespaceManager);

    XPathNavigator repTable = details.SelectSingleNode("my:DatesChoose", NamespaceManager); XPathNavigator node;

    try

    {

    string startDateValue = xPathNavi.SelectSingleNode("/my:myFields/my:fieldStartDate", NamespaceManager).Value;

    string endDateValue = xPathNavi.SelectSingleNode("/my:myFields/my:fieldEndDate", NamespaceManager).Value;

    if (!String.IsNullOrEmpty(startDateValue) && !String.IsNullOrEmpty(endDateValue))

    {

    DateTime startDate = DateTime.Parse(xPathNavi.SelectSingleNode("/my:myFields/my:fieldStartDate", NamespaceManager).ToString());

    DateTime endDate = DateTime.Parse(xPathNavi.SelectSingleNode("/my:myFields/my:fieldEndDate", NamespaceManager).ToString());

    TimeSpan startEnd = endDate.Subtract(startDate);

    int counter = startEnd.Days + 1;

    for (int i = 0; i < counter; i++)

    {

    if (startDate <= endDate)

    {

    node = repTable.Clone();

    node.SelectSingleNode(
    "my:fieldLeaveDate", NamespaceManager).SetValue(startDate.ToShortDateString());node.SelectSingleNode("my:fieldDayOfWeek", NamespaceManager).SetValue(startDate.DayOfWeek.ToString());

    details.AppendChild(node);

    startDate = startDate.AddDays(1);

    }

    }

    // delete a specific range of nodes

    XPathNodeIterator rows = details.Select("my:DatesChoose", NamespaceManager);

    XPathNavigator first = details.SelectSingleNode("my:DatesChoose[1]", NamespaceManager);

    XPathNavigator second = details.SelectSingleNode("my:DatesChoose[" + Convert.ToString(rows.Count - counter) + "]", NamespaceManager);

    first.DeleteRange(second);

    rows = details.Select(
    "my:DatesChoose", NamespaceManager);

    double rowCount = rows.Count;

    int satSunCount = 0;for (int i = 1; i < rowCount + 1; i++)

    {

    String[] satOrSunArr = details.SelectSingleNode("my:DatesChoose[" + i + "]", NamespaceManager).Value.Split(new Char[] { '\n', '\t' });

    string satOrSun = satOrSunArr.GetValue(8).ToString();string halfDay = satOrSunArr.GetValue(12).ToString(); if (satOrSun == "Saturday" || satOrSun == "Sunday")

    {

    satSunCount += 1;

    }

    if (halfDay == "0.5")

    rowCount -= 0.5;

    _totalAbsentDays = rowCount - satSunCount;

    }

    xPathNavi.SelectSingleNode(
    "/my:myFields/my:fieldTotalAbsentDays", NamespaceManager).SetValue(_totalAbsentDays.ToString() + " day(s)");

    }

    }

    catch

    { }

    }

    Thanks

    q
  • 12-01-2008 07:58 PM In reply to

    Hi all,

    It seems the fields in "browser form" don't change immediately after changing value.

    Any ideas?

    Thanks

    q
  • 12-01-2008 09:32 PM In reply to

     Hi,

    Can you go through the following link. It may solve your problem.

    http://www.infopathdev.com/forums/p/6820/24967.aspx#24967

    Swathip
    www.ggktech.com
  • 12-01-2008 09:43 PM In reply to

    Yeah, You are right.

    Thanks a lot

    q
Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.