Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
i have div


XML
<div id="ulAndil" runat="server">

</div>



and button



XML
<pre lang="xml">&lt;asp:Button ID="btnAssignJudToCourse" runat="server" Text="تاكيد "
      CssClass="button" CausesValidation="false" OnClientClick="javascript:getShape();" onclick="btnAssignJudToCourse_Click" Visible="false">




at run time i created alot of sortable html controls and then click confirm i want to save inner html of this div before postback of button in session or anything using jquerey so when user click the button jquerey take inner html of div and store it in cookie session any thing to store it after postback i can retrieve it

please i want the exact code for this j query or javascript method and how to call on button
Posted

1 solution

Hi,

First remove the runat="server" from the DIV and add a Hidde field with runat="server" on your aspx page like:

XML
<input type="hidden" id="hdHTML" runat="server" />


and now store the InnerHTML in the Hidden field

XML
<script type="text/javascript">
       $(document).ready(function () {
           $('#btnAssignJudToCourse').click(function () {
               $('#hdHTML').val($('#ulAndil').html());
           });
       });
   </script>


now on the cs page get the HTML like

C#
protected void btnAssignJudToCourse_Click(object sender, EventArgs e)
{
     string html = this.hdHTML.Value;
}


if you are using Master Page then the IDs for server controls may be different as it start with ContentBody_. please check it and use if you are using master page.
good luck.
 
Share this answer
 
v2
Comments
nagiub2007 10-Apr-12 8:54am    
thank u very much but i wanna 2 say 2 points
1_ ihave to remove run at server from div? as i used it when created runtime controls so can i leave this tag or what

2 yes i have nasterpage but i didnot understand what difference which ids will change?
sorry for thi but iam beginner
tanweer 10-Apr-12 9:01am    
if you are using the dive in code behind then its OK leave the Runat=server.
if you are using mster page then server control ID will be changed and btnAssignJudToCourse is no more access in the javascript, so you need to get its actual ID generated. Right click on the page--go to View Page Source and look you IDs for Button, Hidden Field and the Div. its will be Looks like ContentBody_btnAssignJudToCourse or ctl00_ContentBody_btnAssignJudToCourse, this should be get your self and use this ID (from the page source) in the jquery.
nagiub2007 10-Apr-12 9:03am    
ok in button in aspx ihave to write like OnClientClick="getShape();" or leave it
nagiub2007 10-Apr-12 9:26am    
u help me alot but in jq depuger depuger not pass over j query method so every thing still null
tanweer 11-Apr-12 0:32am    
you don't need to add OnClientClick here.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900