Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Calling a serverside method by __doPostBack()?

Calling a serverside method by __doPostBack()?

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestionannouncement
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridip Bhattacharjee
    wrote on last edited by
    #1

    Suppose i have a server side method called Update() and i have one dropdown. when user select any element from dropdown then how could i call the server side method Update() by __doPostBack(). is it possible to call directly the method Update() by __doPostBack() if so then please help me with a sample code. Thanks in advance.

    tbhattacharjee

    V A 2 Replies Last reply
    0
    • T Tridip Bhattacharjee

      Suppose i have a server side method called Update() and i have one dropdown. when user select any element from dropdown then how could i call the server side method Update() by __doPostBack(). is it possible to call directly the method Update() by __doPostBack() if so then please help me with a sample code. Thanks in advance.

      tbhattacharjee

      V Offline
      V Offline
      Viral Upadhyay
      wrote on last edited by
      #2

      Tridip Bhattacharjee wrote:

      is it possible to call directly the method Update() by __doPostBack()

      Directly No. but you can call any button event in __doPostBack(). So make hidden button any call it by __doPostBack() and in this event call your Update() method. Viral

      Viral My Site Tips & Tracks

      1 Reply Last reply
      0
      • T Tridip Bhattacharjee

        Suppose i have a server side method called Update() and i have one dropdown. when user select any element from dropdown then how could i call the server side method Update() by __doPostBack(). is it possible to call directly the method Update() by __doPostBack() if so then please help me with a sample code. Thanks in advance.

        tbhattacharjee

        A Offline
        A Offline
        amitabha123
        wrote on last edited by
        #3

        Check This Example: .aspx <%@ Page Language="C#" AutoEventWireup="true" CodeFile="test-file-upload1.aspx.cs" Inherits="test_file_upload1" %> <!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>Untitled Page</title> <script language="javascript" > function PostBack(t) { __doPostBack('Test',t.value); } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server"> <asp:ListItem Value="1">1</asp:ListItem> <asp:ListItem Value="2">2</asp:ListItem> <asp:ListItem Value="3">3</asp:ListItem> <asp:ListItem Value="4">4</asp:ListItem> </asp:DropDownList> </div> </form> </body> </html> .cs using System; using System.Data; using System.Configuration; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using System.IO; public partial class test_file_upload1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { DropDownList1.Attributes.Add("onchange", "PostBack(this);"); if (IsPostBack) { string strControlName = ""; strControlName = Request.Params.Get("__EVENTTARGET"); if (strControlName == "Test") { string strArgument = ""; strArgument = Request.Params.Get("__EVENTARGUMENT"); Update(strArgument); } } } private void Update(string strTest) { Response.Write("You have selectecd: " + strTest); } }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups