Header

Monday, 28 May 2012

How to Call JavaScript function inside any event of server control like button click

It is simple just need to use some property of page, like i am using in my example. With this example i am also trying to show u how can we write Button click on ASPX page that called inline code.


<html>
<head runat="server">
    <title></title>
    <script type="text/javascript" >

        function hello() {
            alert("hello");
             }

    </script>
</head>
<body>

<script language="c#" runat="server" >

    protected void Button1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "Jatin Don";
        Page.ClientScript.RegisterStartupScript(this.GetType(), "javascript", "hello()", true);
        
    }
 </script>

    <form id="form1" runat="server">
    <div>

    </div>
    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"/>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </form>
</body>
</html>

Wednesday, 23 May 2012

How to show 3 items in one row in repeater


It is easy to show two items in a single row in any Repeater but when we need to show more then two item in single row we face problem.
But everything have a solution and the solution is here
check this code it will help you to comeout from this problem.....


If anything is wrong let me know i will come back to ur problem.
And drop your Feedback tooooooooooooo :D



<table>
 <asp:Repeater ID="rptTest" runat="server">
  <ItemTemplate>
   <%# IIf(((Container.ItemIndex) Mod 3) = 0, "<tr>", "")%>
  <td>
   <asp:Label ID="getval" runat="server" Text='<%#Eval("Name")>'></asp:Label>
  </td>
   <%# IIf((Container.ItemIndex + 3) Mod 3 = 2,"</tr>", "")%>
  </ItemTemplate>
 </asp:Repeater>
</table>

How to identify Browser using Javascript

Hi Friends,

We will see how we can get the client browser information.

Let see an example, like if we want to know is this browser Chrome or not then we can

In JavaScript we have object which will let us know the information of client browser.

//navigator.userAgent


 if( navigator.userAgent.toLowerCase().indexOf('chrome')>-1)
{
alert("it is chrome");
} 
else
{
alert("it is not Chrome");
}

In the above we are checking the name of Browser in the same way you can find the name.






Thursday, 17 May 2012

JavaScript to read SharePoint list items

<script type="text/javascript" style="font-size: 14px">


 $(function(){
SP.SOD.executeOrDelayUntilScriptLoaded(execClientOM, 'SP.js');

})
function execClientOM() {
alert("exe");
    context = SP.ClientContext.get_current();
alert(context);
    var list = context.get_web().get_lists().getByTitle("Programmes");
    var camlQuery = SP.CamlQuery.createAllItemsQuery();
    this.listItems = list.getItems(camlQuery);

    context.load(listItems);

    context.executeQueryAsync(ReadListItemSucceeded,
                              ReadListItemFailed);
}

function ReadListItemSucceeded(sender, args) {
    var itemsString = '';
    var enumerator = listItems.getEnumerator();

    while (enumerator.moveNext()) {
        var listItem = enumerator.get_current();
        itemsString += listItem.get_item('Title') + '\n';
    }

    alert(itemsString);
}

function ReadListItemFailed(sender, args) {
    alert('Request failed. ' + args.get_message() + '\n' +
          args.get_stackTrace());
} </script>

Monday, 14 May 2012

How to Check query String is exist or not

Imports System.Collections.Specialized

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim n As NameValueCollection = Request.QueryString
' See if any query string exists
 If n.HasKeys() Then
            Dim k As String = n.GetKey(0)
            Dim v As String = n.[Get](0)
            Response.Write(v)
            Response.Write(k)
 End If
End Sub



.............................................
I hope this code will help u :D
Thanks And Regards,
Shailendra Kumar Singh