G
Guest
Language: c#,.net 2
This looks simple in concept: I have a page that needs to display a userid,
a date/time to start vacation, a date/time to end the vacation, and two
buttons: one says approve, the other deny. When you press Approve, it
updates the sql table from pending to approved, when you press deny, it
updates the sql table from pending to denied.
The simplest solution looks to be a repeater which will display the three
data fields, and then the two buttons.
That code is below, and works fine -- that is until I click either approve
or deny.
The code-behind page (also shown below) does not fire, and I get a
validation error (also shown below).
I've looked at several items posted about the error message, and I've tried
setting the page directive to turn off validation (the error message goes
away, but the Label doesn't change = no event firing in my mind at least),
and I belive that the causesvalidation = "false" should override that
behavior for the buttons, but apparently that ain't so either, so I am in a
quandry.
Any suggestions or alternative approaches would be greatly appreciated.
<asp:Repeater runat="server" id="Repeater1" >
<HeaderTemplate>
<table cellpadding="5" cellspacing = "2" border="1"><font
size="2" face="Verdana">
<tr bgcolor = "BurlyWood">
<td><b>Name</b></td>
<td><b>From</b></td>
<td><b>To</b></td>
<td><b> </b></td>
<td><b> </b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="AntiqueWhite">
<td><%# DataBinder.Eval(Container.DataItem,
"EmployeeID") %></td>
<td><%# DataBinder.Eval(Container.DataItem,
"StartDate")%></td>
<td><%# DataBinder.Eval(Container.DataItem,
"EndDate")%></td>
<td><asp:Button text="Approve" runat="server"
ID="Approve" CommandName="Approve" CausesValidation="false" /></td>
<td><asp:Button text ="Deny" runat="server" ID="Deny"
CommandName="Deny" CausesValidation="false" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</font>
</table>
</FooterTemplate>
</asp:Repeater>
Code-Behind:
void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Label1.Text = e.CommandName.ToString();
}
Error Message:
Invalid postback or callback argument. Event validation is enabled using
<pages enableEventValidation="true"/> in configuration or <%@ Page
EnableEventValidation="true" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate from
the server control that originally rendered them. If the data is valid and
expected, use the ClientScriptManager.RegisterForEventValidation method in
order to register the postback or callback data for validation.
This looks simple in concept: I have a page that needs to display a userid,
a date/time to start vacation, a date/time to end the vacation, and two
buttons: one says approve, the other deny. When you press Approve, it
updates the sql table from pending to approved, when you press deny, it
updates the sql table from pending to denied.
The simplest solution looks to be a repeater which will display the three
data fields, and then the two buttons.
That code is below, and works fine -- that is until I click either approve
or deny.
The code-behind page (also shown below) does not fire, and I get a
validation error (also shown below).
I've looked at several items posted about the error message, and I've tried
setting the page directive to turn off validation (the error message goes
away, but the Label doesn't change = no event firing in my mind at least),
and I belive that the causesvalidation = "false" should override that
behavior for the buttons, but apparently that ain't so either, so I am in a
quandry.
Any suggestions or alternative approaches would be greatly appreciated.
<asp:Repeater runat="server" id="Repeater1" >
<HeaderTemplate>
<table cellpadding="5" cellspacing = "2" border="1"><font
size="2" face="Verdana">
<tr bgcolor = "BurlyWood">
<td><b>Name</b></td>
<td><b>From</b></td>
<td><b>To</b></td>
<td><b> </b></td>
<td><b> </b></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr bgcolor="AntiqueWhite">
<td><%# DataBinder.Eval(Container.DataItem,
"EmployeeID") %></td>
<td><%# DataBinder.Eval(Container.DataItem,
"StartDate")%></td>
<td><%# DataBinder.Eval(Container.DataItem,
"EndDate")%></td>
<td><asp:Button text="Approve" runat="server"
ID="Approve" CommandName="Approve" CausesValidation="false" /></td>
<td><asp:Button text ="Deny" runat="server" ID="Deny"
CommandName="Deny" CausesValidation="false" /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</font>
</table>
</FooterTemplate>
</asp:Repeater>
Code-Behind:
void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
{
Label1.Text = e.CommandName.ToString();
}
Error Message:
Invalid postback or callback argument. Event validation is enabled using
<pages enableEventValidation="true"/> in configuration or <%@ Page
EnableEventValidation="true" %> in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate from
the server control that originally rendered them. If the data is valid and
expected, use the ClientScriptManager.RegisterForEventValidation method in
order to register the postback or callback data for validation.