locked
Sharepoint designer: Postback in Javascript RRS feed

  • Question

  • Code:

    function fillDefaultValues()
     {
      var affectedSystemTable = document.getElementById('ctl00_PlaceHolderMain_g_bd0d8439_f917_4a80_93aa_928e4114e057_ff12_1_ctl00_ctl00_OuterTable');
      affectedSystemTable.onpropertychange = checkforWaitCursorOnAffectedSystemBox;
      //if(!Page.IsPostBack) {THIS IS NOT WORKING PLS TELME HOW CAN I DO THIS I WANT THE FUNCTION TO RUN ONLY WHEN ITS POST BACK.}
      {
      setChangeRequestor();
      }
     }

    Friday, January 15, 2010 8:59 PM

Answers

  • I got the solution to it... Hope someone else can use it...

    I created a UserCtrl with a hidden Input & the pasted a true & false text to it based on the postback

    then in javascript it its tru the perform ABC if false perform YYY

    This is working fine... Its just a thought that I could think ..

    If you liked my asnwer pls vote me...
    • Proposed as answer by Parvez Akkas Thursday, January 21, 2010 4:10 AM
    • Marked as answer by Lu Zou-MSFT Friday, January 22, 2010 8:10 AM
    • Unmarked as answer by Manu Kaura Friday, January 22, 2010 4:38 PM
    • Marked as answer by Manu Kaura Friday, January 22, 2010 4:38 PM
    Wednesday, January 20, 2010 6:35 PM

All replies

  • You should start with describing/explaining the issue before getting into copy/pasting codes. Who knows... there might be an easier way of doing the same thing.

    All I can tell from your function name is that you are trying to set default value of a field. For this, you don't need any code. You can set default values for fields from List Settings page and clicking on the column names


    Pman
    http://www.pmansLab.com/
    Saturday, January 16, 2010 3:16 AM
  • My Bad.. :)

    This is the scenario... we have a create new list item page which has some javascript to get the current user defaulted at one of the fields... this can be edited to so if you want to write some other persons name you can do that...

    Problem is here...

    when we change the current username to some other persons name.. there is a cascaded drop dpwn in this form which actually refereshes the form & we lose this other username to current user the defaulter username JS is called......

    How can I avoid this.. If I can use IsNotPostBack event.. How can I do that in Javascript

    Code:

    function fillDefaultValues()
     {
      var affectedSystemTable = document.getElementById('ctl00_PlaceHolderMain_g_bd0d8439_f917_4a80_93aa_928e4114e057_ff12_1_ctl00_ctl00_OuterTable');
      affectedSystemTable.onpropertychange = checkforWaitCursorOnAffectedSystemBox;
      //if(!Page.IsPostBack) {THIS IS NOT WORKING PLS TELME HOW CAN I DO THIS I WANT THE FUNCTION TO RUN ONLY WHEN ITS POST BACK.}
      {
      setChangeRequestor();
      }
     }



    Pls help
    Monday, January 18, 2010 3:43 PM
  • This is the scenario... we have a create new list item page which has some javascript to get the current user defaulted at one of the fields... this can be edited to so if you want to write some other persons name you can do that...

    Problem is here...

    when we change the current username to some other persons name.. there is a cascaded drop dpwn in this form which actually refereshes the form & we lose this other username to current user the defaulter username JS is called......

    hmmm... I don't think there is any easy way. I guess the field is "Person/Group" type where you can choose a user. If so, you can't set default value using out of the box feature.

    Since your cascaded drop down feature is refreshing the page/form, I don't think you'll be able fix it. When the page loads/refreshed, it runs the same javascript code and so, your manually entered value will be overwritten. You don't have a way of checking old value and current value on that field.

    Why don't you use ajax methods for the cascading features. That way your page/form won't refresh and you can avoid this. Marc has a javascript library that includes cascaded drop down feature using sharepoint's web services. I haven't actually tried it myself. But check it out. May be it'll help you.

    http://spservices.codeplex.com/



    Pman
    http://www.pmansLab.com/
    Tuesday, January 19, 2010 1:50 AM
  • I got the solution to it... Hope someone else can use it...

    I created a UserCtrl with a hidden Input & the pasted a true & false text to it based on the postback

    then in javascript it its tru the perform ABC if false perform YYY

    This is working fine... Its just a thought that I could think ..

    If you liked my asnwer pls vote me...
    • Proposed as answer by Parvez Akkas Thursday, January 21, 2010 4:10 AM
    • Marked as answer by Lu Zou-MSFT Friday, January 22, 2010 8:10 AM
    • Unmarked as answer by Manu Kaura Friday, January 22, 2010 4:38 PM
    • Marked as answer by Manu Kaura Friday, January 22, 2010 4:38 PM
    Wednesday, January 20, 2010 6:35 PM
  • Thanx pl7626
    Looking into ur input as well.
    Wednesday, January 20, 2010 7:04 PM
  • I got the solution to it... Hope someone else can use it...

    I created a UserCtrl with a hidden Input & the pasted a true & false text to it based on the postback

    then in javascript it its tru the perform ABC if false perform YYY

    This is working fine... Its just a thought that I could think ..

    If you liked my asnwer pls vote me...

    Actually, I think that's a good and easier workaround for it. It's basically allowing you to check your default value before replacing it. Good work.



    Pman
    http://www.pmansLab.com/
    Thursday, January 21, 2010 4:10 AM