Link to home
Start Free TrialLog in
Avatar of crundle
crundle

asked on

How to preform updatepanel postback from javascript

Need to do a partial page post back from javascript, I have it now  but the whole page post back. When I set it to UpdateMode="Conditional" everything else on the page post back not the section I need.
 
<div class="box-3">
                                                                 Service<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" > 
<ContentTemplate> 
<asp:DropDownList ID="cmbNewService" runat="server" DataTextField="Serv_Type" DataValueField="pk_CarrierID">
</asp:DropDownList>
<asp:LinkButton ID="LinkButton1" runat="server" style="display:none;" onclick="textboxchange" > 
LinkButton </asp:LinkButton>
</ContentTemplate> 
</asp:UpdatePanel> 
</div>

Open in new window

below is the java being called

  function raiseAsyncPostback() {
      __doPostBack("<%= me.LinkButton1.UniqueID %>", "");
  }

Open in new window

Avatar of santhimurthyd
santhimurthyd
Flag of United States of America image

Change the code as follows and try

function raiseAsyncPostback() {
    document.getElementById("<%=  LinkButton1.UniqueID%>").click();
 }

Avatar of crundle
crundle

ASKER

No effect, nothing was posted back. HTML code below from rendering.


 function raiseAsyncPostback() {
      document.getElementById("ctl00$MainContent$LinkButton1").click();
   // __doPostBack("ctl00$MainContent$LinkButton1", "");
 }
 <div id="MainContent_UpdatePanel1">
      
                                                                        <select name="ctl00$MainContent$cmbNewService" id="MainContent_cmbNewService">
            <option value="1::1">Port\Port</option>
            <option value="1::2">Port\Door</option>
 
      </select>
<a id="MainContent_LinkButton1" href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$MainContent$LinkButton1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))" style="display:none;">
                                                                            LinkButton
                                                                        </a>
Are your using the VS2010 and asp.Net 4.0 for the development,

then add the below attribute ClientIDMode="Inherit" to the control and check


<asp:LinkButton ID="LinkButton1" runat="server" style="display:none;" onclick="textboxchange" ClientIDMode="Inherit"
LinkButton </asp:LinkButton>
ASKER CERTIFIED SOLUTION
Avatar of santhimurthyd
santhimurthyd
Flag of United States of America image

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 crundle

ASKER

tried both and didn't fire. I'll setup a demo page to see if something else is causing the problem.
I have identified the issue in the control declaration

style="visibility:hidden;"

<asp:LinkButton ID="LinkButton1" runat="server" style="visibility:hidden;" onclick="textboxchange" ClientIDMode="AutoID" > 
LinkButton </asp:LinkButton>

change the option display to visibility.
Check this for the clarification as why the event is not get fired for "dispaly:none"
http://webdesign.about.com/od/css/f/blfaqhidden.htm