none
Get Edit Mode Panel Field Value through java script

    Question

  • I have define a text field in Edit Mode Panel that is visible in page edit mode. I want to get this field value through java script in display mode, how can I achieve this? 

    Thanks


    Engr. Mudassar Ali Software Engineer

    Monday, March 12, 2012 10:16 AM

All replies

  • Anyone here who can answer?

    Engr. Mudassar Ali Software Engineer

    Wednesday, March 14, 2012 4:20 AM
  • Hi ,

    I understand that you want to get the field value in display mode of a page using JavaScript .Since the field is in Edit Mode Panel and it
    only displays in Edit mode ,you cannot get the value  in display mode using JavaScript .JavaScript van only get the values which is shown on a page .

    You can make the Edit Control Panel shown in display mode of a page instead by using the code below .

    <PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Display">

      <!-- Content you want visible to users *with* 'edit' permissions and in display mode goes here -->

    </PublishingWebControls:EditModePanel>

    <PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Edit">

    <!-- Content you want visible to users *with* 'edit' permissions and in edit mode goes here -->

    </PublishingWebControls:EditModePanel>

    Thanks


    Entan Ming

    TechNet Community Support

    Wednesday, March 14, 2012 6:23 AM
  • I have define a field in Edit Mode Panel on page layout. When i create a new page from this layout then user can add an external link in edit mode panel field. Now if user entered an external link then on this page load I want to redirect the user to that particular link. So i want to get that field value and used it in javascript to redirect the page.

    Whats the solution?


    Engr. Mudassar Ali Software Engineer

    Wednesday, March 14, 2012 10:25 AM
  • Hi ,

    I have added this edit mode panel on my page layout .

    <PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Display">

    <SharePointControls:TextField runat="server" id=TextField1 FieldName="Title" ControlMode=Edit InDesign="True">

    </PublishingWebControls:EditModePanel>

    Added these javascript on the page layout :

    <script type="text\javascript">

    Window.onload=function(){
    var aaa=document.getElementById("textfieldid").value;
    Window.open(aaa);}

    </script>

    You can get the text field id by open the page layout in browser and press F12 to open development tool of IE .Then use the arrow to select the element by click .You will get the textfield id in the HTML .

    Thanks


    Entan Ming

    TechNet Community Support

    Thursday, March 15, 2012 3:45 AM
  • Thanks Entan Ming for your reply.

    I have tried your code but this will show me the Edit Mode Panel Contents in display mode. I want that Edit Mode panel is invisible in display mode but I can get the value of field text from javascript.


    Engr. Mudassar Ali Software Engineer

    Thursday, March 15, 2012 6:15 AM
  • Hi ,

    As far as I know ,if you hide the edit control mode on the display mode ,you cannot use JavaScript to get the value in the field .When you
    press F12 to open developer tools ,there will not show any message about the field .So you can make this edit control panel to show up on the page ,then hide it using JQuery .Here are the codes you can add on the page layout .

    <script type="text\javascript" src="http://code.jquery.com/jquery-latest.js"></script>

    <script type="text\javascript">

    $(document).ready(function(){

    var aaa=$(#FieldId).val();

    window.open(aaa);

    $("#ct100_MSO_ContentDiv").css("visibility","hidden");})//change " ct100_MSO_ContentDiv" container ID which you van get  like how you get the field id .

    </script>

    Thanks


    Entan Ming

    TechNet Community Support

    Thursday, March 15, 2012 10:44 AM
  • I have defined some fields in edit mode panel that a user can change their values when page is in edit mode. So I want edit mode panel be visible in edit page mode only and want to get a specific field value in display mode.

    As u said I can hide edit mode panel through jquery then how can I display it when page is in edit mode?


    Engr. Mudassar Ali Software Engineer

    Friday, March 16, 2012 4:24 AM