473,756 Members | 7,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

advanced question: making <asp:ButtonColu mn> CausesValidatio n=False

Hi,

i stated that this is an advanced question because i have a post from few
days ago that i received answers to with suggestions that looked good but
did not work, so please if you post a reply make sure your suggestion
actually works.

like a <asp:button> control have a CausesValidatio n property that allows it
to POST a button command event to the server without causing the page to
make validation on form inputs, i need to get the same functionallity to an
<asp:button> culomn with a delete command.

i tried to use the OnItemCreated event of the datagrid, to add this
property, but perhaps becuase the button inside the grid is actually an
array of buttons, setting the property had no effect.

also tried to make an <TemplateItem > with the button inside, but again
setting the property had no effect and the form did passed the validation
check.

please advise, but don't just throw "why don't you try this", and as it did
last time, it did not work.

i'm gessing there must be a way (even use javascript or something) - to make
a command from the grid row without passing the form validation.
TIA, z.

Nov 18 '05 #1
4 2014
Hi z.f:

Perhaps you could post some code to look at. I've tried this with an
ItemTemplate like so:

<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateCol umns="False">
<Columns>
<asp:BoundColum n DataField="au_i d" HeaderText="au_ id"/>
<asp:TemplateCo lumn HeaderText="tes t">
<ItemTemplate >
<asp:Button Runat="server" ID="button1"
CausesValidatio n="False" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
<asp:TextBox Runat="server" ID="textbox1" />
<asp:RequiredFi eldValidator Runat="server"
ID="requiredFie ldValidator"
ControlToValida te="textbox1"
ErrorMessage="Y ou screwed up" />
<asp:Button Runat="server" ID="mainbutton " />
</form>

In this case pressing a button in the DataGrid does not cause
validation.

--
Scott
http://www.OdeToCode.com

On Thu, 24 Jun 2004 11:20:03 +0200, "z. f."
<zi**@info-scopeREMSPAM.co .il> wrote:
Hi,

i stated that this is an advanced question because i have a post from few
days ago that i received answers to with suggestions that looked good but
did not work, so please if you post a reply make sure your suggestion
actually works.

like a <asp:button> control have a CausesValidatio n property that allows it
to POST a button command event to the server without causing the page to
make validation on form inputs, i need to get the same functionallity to an
<asp:button> culomn with a delete command.

i tried to use the OnItemCreated event of the datagrid, to add this
property, but perhaps becuase the button inside the grid is actually an
array of buttons, setting the property had no effect.

also tried to make an <TemplateItem > with the button inside, but again
setting the property had no effect and the form did passed the validation
check.

please advise, but don't just throw "why don't you try this", and as it did
last time, it did not work.

i'm gessing there must be a way (even use javascript or something) - to make
a command from the grid row without passing the form validation.
TIA, z.


Nov 18 '05 #2
i'll check it up ,

for now i managed to do with overriding the Validate method of the page
object and only if i want to, i call
MyBase.Validate ()

but i will try your code as soon as i'll make another grid with delete
buttons etc', that should not make validation of other operation that the
page can do.

question: the button inside the <asp:TemplateCo lumn HeaderText="tes t">, how
it "knows" which id it acts for, do i need to write code in the
OnItemCreated , or it can handle a grid command like delete?

thanx.

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:gj******** *************** *********@4ax.c om...
Hi z.f:

Perhaps you could post some code to look at. I've tried this with an
ItemTemplate like so:

<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateCol umns="False">
<Columns>
<asp:BoundColum n DataField="au_i d" HeaderText="au_ id"/>
<asp:TemplateCo lumn HeaderText="tes t">
<ItemTemplate >
<asp:Button Runat="server" ID="button1"
CausesValidatio n="False" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
<asp:TextBox Runat="server" ID="textbox1" />
<asp:RequiredFi eldValidator Runat="server"
ID="requiredFie ldValidator"
ControlToValida te="textbox1"
ErrorMessage="Y ou screwed up" />
<asp:Button Runat="server" ID="mainbutton " />
</form>

In this case pressing a button in the DataGrid does not cause
validation.

--
Scott
http://www.OdeToCode.com

On Thu, 24 Jun 2004 11:20:03 +0200, "z. f."
<zi**@info-scopeREMSPAM.co .il> wrote:
Hi,

i stated that this is an advanced question because i have a post from few
days ago that i received answers to with suggestions that looked good but
did not work, so please if you post a reply make sure your suggestion
actually works.

like a <asp:button> control have a CausesValidatio n property that allows itto POST a button command event to the server without causing the page to
make validation on form inputs, i need to get the same functionallity to an<asp:button> culomn with a delete command.

i tried to use the OnItemCreated event of the datagrid, to add this
property, but perhaps becuase the button inside the grid is actually an
array of buttons, setting the property had no effect.

also tried to make an <TemplateItem > with the button inside, but again
setting the property had no effect and the form did passed the validation
check.

please advise, but don't just throw "why don't you try this", and as it didlast time, it did not work.

i'm gessing there must be a way (even use javascript or something) - to makea command from the grid row without passing the form validation.
TIA, z.

Nov 18 '05 #3
In this case it would be a little different than the grid delete
command. You can get to the DataGridItem by asking for the sender's
parent, like this:

protected void Button1_Click(o bject sender, System.EventArg s e)
{
Button btn = sender as Button;
// now btn.Parent is equivalent to
// e.Item in DataGrid_Delete command
}

You might also find this article that I wrote helpful:
Tips for locating controls with the FindControl method, including
finding controls in DataGrid rows, Repeaters, DataGrid headers, and
user controls:
http://odetocode.com/Articles/116.aspx

--
Scott

On Thu, 24 Jun 2004 17:22:28 +0200, "z. f."
<zi**@info-scopeREMSPAM.co .il> wrote:
i'll check it up ,

for now i managed to do with overriding the Validate method of the page
object and only if i want to, i call
MyBase.Validat e()

but i will try your code as soon as i'll make another grid with delete
buttons etc', that should not make validation of other operation that the
page can do.

question: the button inside the <asp:TemplateCo lumn HeaderText="tes t">, how
it "knows" which id it acts for, do i need to write code in the
OnItemCreate d , or it can handle a grid command like delete?


--
Scott
http://www.OdeToCode.com
Nov 18 '05 #4
The correct answer to the original question:

In OnItemCreated, retrieve the ButtonColumn object by its index in
e.Item.Cells. Then access the first control in its control collection. That
is the Button control. Finally set CausesValidatio n to false on that
control.

Suppose the buttonColumn was the second column. It uses an index of 1.
Here's code in C#:

Button vButton = (Button) e.Item.Cells[1].Controls[0];
vButton.CausesV alidation = false;

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"z. f." <zi**@info-scopeREMSPAM.co .il> wrote in message
news:uy******** **********@TK2M SFTNGP12.phx.gb l...
i'll check it up ,

for now i managed to do with overriding the Validate method of the page
object and only if i want to, i call
MyBase.Validate ()

but i will try your code as soon as i'll make another grid with delete
buttons etc', that should not make validation of other operation that the
page can do.

question: the button inside the <asp:TemplateCo lumn HeaderText="tes t">, how it "knows" which id it acts for, do i need to write code in the
OnItemCreated , or it can handle a grid command like delete?

thanx.

"Scott Allen" <bitmask@[nospam].fred.net> wrote in message
news:gj******** *************** *********@4ax.c om...
Hi z.f:

Perhaps you could post some code to look at. I've tried this with an
ItemTemplate like so:

<form id="Form1" method="post" runat="server">
<asp:DataGrid id="DataGrid1" runat="server"
AutoGenerateCol umns="False">
<Columns>
<asp:BoundColum n DataField="au_i d" HeaderText="au_ id"/>
<asp:TemplateCo lumn HeaderText="tes t">
<ItemTemplate >
<asp:Button Runat="server" ID="button1"
CausesValidatio n="False" />
</ItemTemplate>
</asp:TemplateCol umn>
</Columns>
</asp:DataGrid>
<asp:TextBox Runat="server" ID="textbox1" />
<asp:RequiredFi eldValidator Runat="server"
ID="requiredFie ldValidator"
ControlToValida te="textbox1"
ErrorMessage="Y ou screwed up" />
<asp:Button Runat="server" ID="mainbutton " />
</form>

In this case pressing a button in the DataGrid does not cause
validation.

--
Scott
http://www.OdeToCode.com

On Thu, 24 Jun 2004 11:20:03 +0200, "z. f."
<zi**@info-scopeREMSPAM.co .il> wrote:
Hi,

i stated that this is an advanced question because i have a post from fewdays ago that i received answers to with suggestions that looked good butdid not work, so please if you post a reply make sure your suggestion
actually works.

like a <asp:button> control have a CausesValidatio n property that allows
it
to POST a button command event to the server without causing the page
tomake validation on form inputs, i need to get the same functionallity to
an<asp:button> culomn with a delete command.

i tried to use the OnItemCreated event of the datagrid, to add this
property, but perhaps becuase the button inside the grid is actually an
array of buttons, setting the property had no effect.

also tried to make an <TemplateItem > with the button inside, but again
setting the property had no effect and the form did passed the
validationcheck.

please advise, but don't just throw "why don't you try this", and as it

didlast time, it did not work.

i'm gessing there must be a way (even use javascript or something) - to makea command from the grid row without passing the form validation.
TIA, z.


Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1810
by: GrantS | last post by:
I am trying to convert the VB.Net code example povided by http://authors.aspalliance.com/JimRoss/Articles/MaintainScrollPos.aspx into C# (ASP.Net)without success. No errors are thrown in the VB code provided on the website. Once I have this example running correctly, I will need to use the concept in a more complex project. The code I am using involves an webform and an htc file. The code for ScrollPos.htc (which is located in a folder...
12
2879
by: James Norton-Jones | last post by:
Hi, Am I trying to hold the data of a DataGrid in a label so that when the form is reposted the DataGrid can be repopulated. The problem I am having is that I don't understand how to get the text into a stream in order to be able to use DataSetOutcomes1.ReadXML(MyStream). Thanks in advance, James
4
2287
by: z. f. | last post by:
Hi, I'm having an aspx page with a server form. i have a grid with a delete button and below the grid, another area with inputs for inserting new values and an "add" button for submiting the lower area of the form. on the lower area i have validators for validating input.
6
3164
by: z. f. | last post by:
Hi, i have a datagrid with a delete button for each row in the grid. when the delete button is clicked i need to ask the user in a "confirm" message box if he's sure he wants to delete. the problem is that the <asp:ButtonColumn ButtonType="PushButton" CommandName="Delete" .... don't have a property to allow onclick to run client side script . how can this be,
7
5271
by: Alex Maghen | last post by:
I have a DataGrid control with a LinkButton command column that deletes the row. What I want to do is set it up so that there's a client-side Confirm alert BEFORE the actual Delete command gets called on the server-side. That's easy to do with normal buttons, etc. as follows... <asp:Button ID="ConfirmBtn" Text="ConfimMe!" OnClientClick="if(!confirm('Are you sure?'))return false;" OnClick="ConfirmBtnClickHandler" Runat="server" /> But...
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10040
Oralloy
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...
0
9873
jinu1996
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...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
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...
0
5142
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...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3359
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.