G
Guest
Hi,
I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes a few seconds. The js function simply sets the css style to display.
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton Runat="server" CommandName="Select" ID="lbtnCompanyName">
<%# DataBinder.Eval(Container.DataItem, "CompanyName")%>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
The server side code to add the javascript "onclick" handler to the templated column above...
LinkButton company = (LinkButton)e.Item.Cells[0].Controls[1];
company.Attributes.Add("onclick", "getCompanyInfo()");
The resulting HTML for one of the datagrid rows....
<a id="dgCompanyList__ctl5_lbtnCompanyName" onclick="getCompanyInfo()" href="javascript:__doPostBack('dgPortfolio$_ctl5$lbtnCompanyName','')">Acme, Inc.</a>
The js function doesn't seem to get called and the postback occurs anyway. The strange thing is if I say "return getCompanyInfo()" and the function returns false, the message appears but the form submit is cancelled.
Should I execute the js function AFTER the postback is called so it's display until the page is refreshed? If so how do I get it execute after _doPostBack?
Thanks, Dave.
I have a datagrid with a Templated column below. I want to execute some javascript before the postback to show a hidden "div" tag with static message of "Please Wait..." since the query takes a few seconds. The js function simply sets the css style to display.
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton Runat="server" CommandName="Select" ID="lbtnCompanyName">
<%# DataBinder.Eval(Container.DataItem, "CompanyName")%>
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
The server side code to add the javascript "onclick" handler to the templated column above...
LinkButton company = (LinkButton)e.Item.Cells[0].Controls[1];
company.Attributes.Add("onclick", "getCompanyInfo()");
The resulting HTML for one of the datagrid rows....
<a id="dgCompanyList__ctl5_lbtnCompanyName" onclick="getCompanyInfo()" href="javascript:__doPostBack('dgPortfolio$_ctl5$lbtnCompanyName','')">Acme, Inc.</a>
The js function doesn't seem to get called and the postback occurs anyway. The strange thing is if I say "return getCompanyInfo()" and the function returns false, the message appears but the form submit is cancelled.
Should I execute the js function AFTER the postback is called so it's display until the page is refreshed? If so how do I get it execute after _doPostBack?
Thanks, Dave.