I have a content page and inside my content page, i have Ajax Tab Container which consist of two different tabs. Within the tabs, i have two different grids.
What i m trying to achive is; load the second tab when user clicks on it using the doPostBack function which basically do the following work:
__doPostBack('Btn1', ' ');
Sub Btn1_OnClick(sender As Object, e As EventArgs)
............
Your button click contains some code that you would like to execute. Move the code kept in the button click to a seperate method and then call that method in the button click as well as explicitly:
Eg :
Private Sub CallMe(ByVal sender As Object, ByVal E As EventArgs)
' your button click code
End Sub
Private Sub Btn1_OnClick(sender ByVal [Object] As [As], e ByVal EventArgs As [As])
CallMe()
End Sub
You can then call the desired code explicitly using :
You should do it like this, __doPostBack("Btn1's Client Name",""), please be careful, not ClientID but ClientName. Here is a wrokable sample, please compare mine with yours.
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
saqib_dotnet
Member
292 Points
619 Posts
__doPostback function from the Content Page (Master Page Architecture)
Dec 31, 2007 12:21 AM|LINK
Hi
I have a content page and inside my content page, i have Ajax Tab Container which consist of two different tabs. Within the tabs, i have two different grids.
What i m trying to achive is; load the second tab when user clicks on it using the doPostBack function which basically do the following work:
__doPostBack('Btn1', ' ');
Sub Btn1_OnClick(sender As Object, e As EventArgs)
............
End Sub
<input id="Btn1" runat="server" type="button" style="display:none" onServerClick="Btn1_OnClick" />
My problem is; the onclick event doesnt fire on doPostBack. it just refreshes the page. How can i call the onClick event for button 1?
Regards
Suprotim Aga...
Star
14263 Points
1973 Posts
MVP
Re: __doPostback function from the Content Page (Master Page Architecture)
Dec 31, 2007 02:24 AM|LINK
Hi,
Your button click contains some code that you would like to execute. Move the code kept in the button click to a seperate method and then call that method in the button click as well as explicitly:
Eg :
Private Sub CallMe(ByVal sender As Object, ByVal E As EventArgs)
' your button click code
End Sub
Private Sub Btn1_OnClick(sender ByVal [Object] As [As], e ByVal EventArgs As [As])
CallMe()
End Sub
You can then call the desired code explicitly using :
CallMe(this, EventArgs.Empty);
HTH,
Suprotim Agarwal
-----
http://www.dotnetcurry.com
-----
ASP.NET with jQuery Articles | ASP.NET Tips and Tricks
saqib_dotnet
Member
292 Points
619 Posts
Re: __doPostback function from the Content Page (Master Page Architecture)
Dec 31, 2007 03:56 PM|LINK
But like i said, my doPostBack function doesnt even fire the btn1_OnClick event. it just refreshes the page.
I m using dopostback in javascript to call the btn_Click event to do the asyncronous postback. Thats my main intention is.
Jonathan She...
All-Star
31269 Points
3445 Posts
Re: __doPostback function from the Content Page (Master Page Architecture)
Jan 04, 2008 02:18 AM|LINK
Hi Saqid_dotnet,
You should do it like this, __doPostBack("Btn1's Client Name",""), please be careful, not ClientID but ClientName. Here is a wrokable sample, please compare mine with yours.
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Btn2_Click(object sender, EventArgs e) { } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <ajaxToolkit:TabContainer ID="TabContainer1" runat="server" AutoPostBack="true" ActiveTabIndex="1"> <ajaxToolkit:TabPanel runat="server" ID="TabPanel1"> <HeaderTemplate> TabPanel1</HeaderTemplate> <ContentTemplate> <asp:Button ID="Btn1" runat="server" Text="Button" /> </ContentTemplate> </ajaxToolkit:TabPanel> <ajaxToolkit:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate> TabPanel2</HeaderTemplate> <ContentTemplate> <asp:Button ID="Btn2" runat="server" Text="Button" onclick="Btn2_Click" /></ContentTemplate> </ajaxToolkit:TabPanel> </ajaxToolkit:TabContainer> <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="postBack();return false;"/> <script type="text/javascript" language="javascript"> function postBack(){ var btnName = $get("<%=Btn2.ClientID%>").name; __doPostBack(btnName,""); } </script> </form> </body> </html>I hope this help.
Best regards,
Jonathan
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
saqib_dotnet
Member
292 Points
619 Posts
Re: __doPostback function from the Content Page (Master Page Architecture)
Jan 04, 2008 01:55 PM|LINK
Great...It worked for me. You right; the name property is the right thing to use to call the doPostback function.
Thanks for your reply.
ronald_yoh
Member
108 Points
519 Posts
Re: __doPostback function from the Content Page (Master Page Architecture)
Dec 23, 2008 07:19 PM|LINK
hey mate.. i had the issue and followed your sample.. now it fixed.. u're legend.. :)
merry xmas..