Solved

__doPostBack Not Working

Posted on 2008-06-18
2
2,105 Views
Last Modified: 2008-10-08
Hi Experts,
    I have a problem Im hoping someone here can help me out here with. I am trying to use an imageButton to call the click event of a link button by doing a forced postback. This should be a simple task, but I have had no luck with this, and am stuck. The code for both the aspx file including the javascript function and the codebehind for the LinkButton_Click event is also posted. Any help to solve this would be appreciated. Thanks in Advance


ASPX

 

 <script type="text/javascript">

    function FillText()

    {

    //debugger;

      __doPostBack('<%= LinkButton1.UniqueID %>', ''); 

     //__doPostBack("LinkButton1","");

    

    }

    </script>

        <asp:ScriptManager ID="ScriptManager1" runat="server">

        </asp:ScriptManager>

        <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">

            <Triggers>

            <asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click" />

            </Triggers>

            <ContentTemplate>

                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CausesValidation="false">LinkButton</asp:LinkButton>

                <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"></asp:TextBox>

                <br />

                <br />

                <div onclick='FillText()'>

                    <asp:ImageButton ID="ImageButton1" runat="server" />

                </div>

            </ContentTemplate>

        </asp:UpdatePanel>

 

C#

 

 protected void LinkButton1_Click(object sender, EventArgs e)

    {

        TextBox1.Text = "Hello There";

        UpdatePanel1.Update();

    }

Open in new window

0
Comment
Question by:groovbox303
2 Comments
 
LVL 29

Accepted Solution

by:
David H.H.Lee earned 250 total points
Comment Utility
Hi groovbox303,
You can trigger the same function in UpdatePanel without javascript.
eg:
  <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional">
            <Triggers>
            <asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click" />
            <asp:AsyncPostBackTrigger ControlID="ImageButton1" EventName="Click" />
            </Triggers>
            <ContentTemplate>
                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" CausesValidation="false">LinkButton</asp:LinkButton>
                <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true"></asp:TextBox>
                <br />
                <br />
                <asp:ImageButton ID="ImageButton1" runat="server" OnClick="ImageButton1_Click" CausesValidation="false"/>
            </ContentTemplate>
        </asp:UpdatePanel>
 

private void ImageButton1_Click(object sender, System.Web.UI.ImageClickEventArgs e)
    {
        LinkButton1_Click(nothing,nothing);
    }

 protected void LinkButton1_Click(object sender, EventArgs e)
    {
        TextBox1.Text = "Hello There";
        UpdatePanel1.Update();
    }
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now