I'm trying to use __doPostBack to pass some data from client to server side. I'm not very expierenced with JS, but when debugging in Firebug something wierd is happening. I'll show my code first.
<script type="text/javascript">
function BeginDownload() {
var temp = $("#waterwheel-carousel-horizon").CurrentSelectedImg().toString()
__doPostBack("ImgDownload", temp);
}
</script>
<asp:LinkButton ID="DownloadLink" runat="server" OnClientClick="BeginDownload()" style="text-align:center">DOWNLOAD IMAGE</asp:LinkButton>
// This code is currently not reached, but I put it here for completion.
#region EventTarget
private string EventTarget
{
get{
return Request.Form["__EVENTTARGET"].ToString().ToUpper();
}
}
#endregion EventTarget
#region HandlePostBack
void HandlePostBack()
{
switch (EventTarget)
{
case "ImgDownload":
DownloadImage(EventArgs);
break;
}
}
#endregion HandlePostBack
private void DownloadImage(string index)
{
string test = index;
}
Ultimately what happens is that I click the linkbutton and firebug jumps to the first line of code, but before it even finishes that function it suddenly jumps to __doPostBack functions code before I even pass in the variables. Why is this happening?
If there is animation effect, then it can be considered like in another thread. So when you look at the code, those two lines are just happen in parallel. You may try to find out if it provides you with something like a callback function that executes after
animiation finishes. You can __doPostBack in that callback.
mtewks
Member
431 Points
308 Posts
Javascript __doPostBack Flow
Jun 20, 2012 05:53 PM|LINK
I'm trying to use __doPostBack to pass some data from client to server side. I'm not very expierenced with JS, but when debugging in Firebug something wierd is happening. I'll show my code first.
<script type="text/javascript"> function BeginDownload() { var temp = $("#waterwheel-carousel-horizon").CurrentSelectedImg().toString() __doPostBack("ImgDownload", temp); } </script> <asp:LinkButton ID="DownloadLink" runat="server" OnClientClick="BeginDownload()" style="text-align:center">DOWNLOAD IMAGE</asp:LinkButton>// Relevant Waterwheel jquery code. $.fn.CurrentSelectedImg = function () { return data.currentCenterItem.data().index; };// This code is currently not reached, but I put it here for completion. #region EventTarget private string EventTarget { get{ return Request.Form["__EVENTTARGET"].ToString().ToUpper(); } } #endregion EventTarget #region HandlePostBack void HandlePostBack() { switch (EventTarget) { case "ImgDownload": DownloadImage(EventArgs); break; } } #endregion HandlePostBack private void DownloadImage(string index) { string test = index; }Ultimately what happens is that I click the linkbutton and firebug jumps to the first line of code, but before it even finishes that function it suddenly jumps to __doPostBack functions code before I even pass in the variables. Why is this happening?
BU XI - MSFT
All-Star
22367 Points
2704 Posts
Microsoft
Re: Javascript __doPostBack Flow
Jun 25, 2012 04:19 AM|LINK
Hello
If there is animation effect, then it can be considered like in another thread. So when you look at the code, those two lines are just happen in parallel. You may try to find out if it provides you with something like a callback function that executes after animiation finishes. You can __doPostBack in that callback.
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework