Thursday, February 16, 2012

Javascript/jquery count li elements inside ul

Below is the script with which you can get the count of li present in ul..


Html::

<ul id="myulid">
  <li>List Item1</li>
  <li>List Item2</li>
  <li>List Item3</li>
  <li>List Item4</li>
  <li>List Item5</li>
</ul>

Java Script:: 


<script type="text/javascript">
var myul = document.getElementById('myulid');
var liCount= myul.getElementsByTagName('li').length;
alert(liCount);
</script>


Hope this helps...

Monday, February 6, 2012

How to call code behind server method from a client side javascript

In this post we will see how to call a server side function from JavaScript.
 

HTML::
<div style="visibility: hidden">
<asp:Button ID="mybtn" runat="Server" onclick="mybtn_Click" />
</div>

Java Script::
var hiddenMyBtn = document.getElementById('<%= mybtn.ClientID %>');
hiddenMyBtn.click();

Server side code::
protected void mybtn_Click(object sender, EventArgs e)
{
//Do your stuff
}


Hope this helps...


Tuesday, January 31, 2012

Build view List item url and Edit List item url-sharepoint 2010



In this post we are going to programatically build view List item url and Edit List item url-sharepoint 2010.
Below is how the url's supposed to be .

View list item url::
http://<site url>/Lists/<ListName>/DispForm.aspx?ID=<ItemID>&Source=/Lists/<ListName>

Edit list item url::
http://<site url>/Lists/<ListName>/EditForm.aspx?ID=<ItemID>&Source=/Lists/<ListName>



Hope this helps...

Popular Posts