what is the use of __doPostback() method and when to use it..? Please give me overview on this.

Posted by Singarapu_kranthi under ASP.NET on 12/30/2009 | Views : 16496 | Status : [Member] | Replies : 3
what is the use of __doPostback() method and when to use it..? Please give me overview on this.




Responses

Posted by: Pardhu2020 on: 6/11/2013 [Member] Starter | Points: 25

Up
0
Down
hi some on pls let me know how to use __PostBack()



Singarapu_kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Pardhu2020 on: 6/11/2013 [Member] Starter | Points: 25

Up
0
Down
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="postback.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script language="javascript" type="text/javascript">
function v() {
var a = document.getElementById("txt1").value;
// alert(a);
if (a == null || a == "") {

alert("enter some thing");
}
else {
alert("test");
}
__doPostBack('btnSave', '')
}

</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt1" runat="server" ></asp:TextBox>
</div>
<div>
<asp:Button ID="btnSave" runat="server" OnClientClick="v();" Text="Click me!"/>
</div>
</form>
</body>
</html>

this is my default.aspx page

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace postback
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void btnSave_Click()

{

}
}
}

how i can call btnSave_Click() useing __PostBack()



Singarapu_kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Virendradugar on: 12/30/2009 [Member] [MVP] Silver

Up
0
Down
__doPostBack() function is used to make server side event call. For example, If you want to call button click (server side) from Javascript then you can use __doPostBack() function.

Check this article.

http://aspalliance.com/895_Understanding_the_JavaScript___doPostBack_Function.all

Thanks,
Virendra Dugar

Singarapu_kranthi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response