About Me

My photo
Muthupet, TamilNadu, India
SharePoint 2010

Tuesday, December 4, 2012

Hyberlink using call JavaScript Function



<Columns>

        <asp:TemplateField>

            <ItemTemplate>

                <asp:LinkButton ID="lnk" runat="server" Text='<%#Eval("Title") %>' OnClientClick="javascript:return OpenDialogbox(this);"></asp:LinkButton>

                <asp:HiddenField ID="hdn" runat="server" Value='<%#Eval("ID")%>' />

            </ItemTemplate>

            <HeaderTemplate>Titel</HeaderTemplate>

        </asp:TemplateField>

 

 

<script language="javascript" type="text/javascript">

    function OpenDialogbox(obj) {

        var item = obj.id;

        item = item.replace("lnk", "hdn");

        var itemid = document.getElementById(item).value;

        alert('saravanan');

        var options = {

            url: "http://igrid108:777/_Layouts/Saravanan_Testsolutions/Edit.aspx?Itemsvalue=" + itemid,

            width: 600,

            height: 300,

            showClose: true,

            title: "Edit Notes"

        };

        SP.UI.ModalDialog.showModalDialog(options);

        return false;

    } 

</script>
 
 
Application page using javascript alert and redirect same page (refresh) script
-------------------------------------------------------------------------------
 
 
using (SPWeb oweb = osite.OpenWeb())

                {

                    SPList olist = oweb.Lists["Tasks"];

                    SPListItem oitem = olist.GetItemById(itemidvalue);

                   

                    oitem["Title"] = TextBox1.Text;

                    oweb.AllowUnsafeUpdates = true;

                    oitem.Update();

                    oweb.AllowUnsafeUpdates = false;

                    Response.Write("<script language='javascript' >alert('Details updated successfully!!'); parent.document.location.href= parent.document.location.href</script>");

 
Some Different Ways..
---------------------
 

                  //  Page.ClientScript.RegisterStartupScript(this.GetType(), "call my function", "alertmsg();", true);

                  //  ClientScript.RegisterStartupScript(GetType(), "hwa", "alert('Item saved sucessfully');", true);

                  //  Response.Write("javascript:return alertmsg();");
}

 



 

No comments:

Post a Comment