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:TemplateCo lumn>
<ItemTemplate >
<asp:LinkButt on Runat="server" CommandName="Se lect" ID="lbtnCompany Name">
<%# DataBinder.Eval (Container.Data Item, "CompanyName")% >
</asp:LinkButton>
</ItemTemplate>
</asp:TemplateCol umn>
The server side code to add the javascript "onclick" handler to the templated column above...
LinkButton company = (LinkButton)e.I tem.Cells[0].Controls[1];
company.Attribu tes.Add("onclic k", "getCompanyInfo ()");
The resulting HTML for one of the datagrid rows....
<a id="dgCompanyLi st__ctl5_lbtnCo mpanyName" onclick="getCom panyInfo()" href="javascrip t:__doPostBack( 'dgPortfolio$_c tl5$lbtnCompany Name','')">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. 2 5582
You can wrap the <asp:LinkButton > in a <span> control that has the
javascript. Use runat=server and Onclick=javascr ipt, I think.
Then when you click the button the javascript runs first.
For example, I have a Delete button and I wrap in a confirm message box.
If the user hits OK then the delete is processed. But if they Cancel, then
it is not.
--
Joe Fallon
"Dave" <Da**@discussio ns.microsoft.co m> wrote in message
news:57******** *************** ***********@mic rosoft.com... 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:TemplateCo lumn> <ItemTemplate > <asp:LinkButt on Runat="server" CommandName="Se lect" ID="lbtnCompany Name"> <%# DataBinder.Eval (Container.Data Item, "CompanyName")% > </asp:LinkButton> </ItemTemplate> </asp:TemplateCol umn>
The server side code to add the javascript "onclick" handler to the
templated column above... LinkButton company = (LinkButton)e.I tem.Cells[0].Controls[1]; company.Attribu tes.Add("onclic k", "getCompanyInfo ()");
The resulting HTML for one of the datagrid rows....
<a id="dgCompanyLi st__ctl5_lbtnCo mpanyName" onclick="getCom panyInfo()"
href="javascrip t:__doPostBack( 'dgPortfolio$_c tl5$lbtnCompany Name','')">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.
You need to have return in onclick event. So the "return getCompanyInfo( )"
is correct, did you check in your js function to make sure there is return
true at the end.
"Joe Fallon" <jf******@nospa mtwcny.rr.com> wrote in message
news:ei******** ******@tk2msftn gp13.phx.gbl... You can wrap the <asp:LinkButton > in a <span> control that has the javascript. Use runat=server and Onclick=javascr ipt, I think. Then when you click the button the javascript runs first. For example, I have a Delete button and I wrap in a confirm message box. If the user hits OK then the delete is processed. But if they Cancel, then it is not. -- Joe Fallon "Dave" <Da**@discussio ns.microsoft.co m> wrote in message news:57******** *************** ***********@mic rosoft.com... 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:TemplateCo lumn> <ItemTemplate > <asp:LinkButt on Runat="server" CommandName="Se lect"
ID="lbtnCompany Name"> <%# DataBinder.Eval (Container.Data Item, "CompanyName")% > </asp:LinkButton> </ItemTemplate> </asp:TemplateCol umn>
The server side code to add the javascript "onclick" handler to the
templated column above... LinkButton company = (LinkButton)e.I tem.Cells[0].Controls[1]; company.Attribu tes.Add("onclic k", "getCompanyInfo ()");
The resulting HTML for one of the datagrid rows....
<a id="dgCompanyLi st__ctl5_lbtnCo mpanyName" onclick="getCom panyInfo()"
href="javascrip t:__doPostBack( 'dgPortfolio$_c tl5$lbtnCompany Name','')">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.
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: THM5101 |
last post by:
Hello
I have two problems with my dataGrid. I created dataGrid
with 4 columns. The first and the last one are LinkButton
type, the second and third are Bound Column type.
My problems are:
1. When I click on one of the LinkButton column(first
or last column), I activate the ItemCommand event of the
dataGrid. My problem is how can I know on which column I
click? The first or the last one? I need to make a
different in my code when the...
|
by: sameer mowade via .NET 247 |
last post by:
Hello All,
I have problem while dynamically removing row from the Datagrid which i have added dynamically as shown in the following code snippet. The problem is that while removing dynamically added row it also removes the row at the end along with the added row.
Plz tell me if, I am missing any thing.
Code
</asp:datagrid>
|
by: Mark Fox |
last post by:
Hello,
I am attempting to do something very simple. I have
a page MainPage.aspx and a popup window Popup.aspx. When
users click on the linkbutton in the popup window I am
looking to do some server side processing in Popup.aspx,
then have the popup window close, and have the
MainPage.aspx do a postback to the server. But I am
having trouble determining what client side javascript
Popup.aspx should render after it does its server side
|
by: Steve |
last post by:
I have a datagrid that is created at run time
DataGrid dgG = new DataGrid();
BoundColumn bcB;
dgG.CellPadding = 5;
dgG.CellSpacing = 0;
dgG.GridLines = GridLines.Both;
dgG.CssClass = "SectionTableLines";
dgG.DataKeyField = "PlanWorkOrderID";
|
by: Daniel Walzenbach |
last post by:
Hi,
I want to display a Label in a DataGrid according to some condition. I therefore check whether the condition is true in the ItemDateBound EventHandler of the DataGrid. Unfortunately the conversion is extremely costly in performance. Does anybody know how I could set the label (of the whole content of the TableCell) to .Visible = False without converting e.Item.Controls(2) to a System.Web.UI.WebControls.Label?
| |
by: Fluxray |
last post by:
--Background:
I have a webform including a datagrid. The datagrid is using template. Its
ItemTemplate is used to display a look-up-table with labels. its
EditItemTemplate is used to edit a row in the look-up-table with textboxes. I
have a linkbutton in each row (causevalidation = false) named 'Edit' to post
the page back such that the page is switch from display mode to edit mode
(labels -> textboxes for the row to be edited), and the...
|
by: JD |
last post by:
Hello Everyone,
I am writing a asp.net page using vb.net with a datagrid control. I am
trying to detect when a row is clicked on in the grid. And I am not sure how
to do this, if anyone has any ideas on this I would really appreciate your
help. Thanks.
--
J. D
|
by: Hardy Wang |
last post by:
Hi all,
We have DataGrid control in Web Form, our client requires to be able to
click anywhere of a row to fire the event same as LinkBotton column is
clicked. We we did in ASP.NET 1.1 is
in ASPX page
<asp:DataGrid id="MyGrid" runat="server" AutoGenerateColumns="False"
AllowSorting="True" AllowPaging="True" runat="server"
EnableViewState="True">
<Columns>
|
by: johnlim20088 |
last post by:
Hi Can anyone help me?
I have a Javascript function in my test.aspx as follow:-
<script language="Javascript">
function confirm_save()
{
if (confirm("Are you sure you want to save this changed?")==true)
return true;
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |