Home All Groups Group Topic Archive Search About
Author
15 Dec 2005 7:10 PM
Amadeus Consulting
I am developing a control in ASP.NET 2.0 that is derived from GridView. This
control handles paging on its own and thus renders custom paging buttons. It
also add some other functionality to the GridView by overriding Render() and
rendering other controls alongside the GridView’s HTML.

When I click one of the pager buttons (of type ImageButton), I receive the
following error:

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.


I have searched for other people that have encountered this error, and the
common suggestion is to specify <pages enableEventValidation=”false” /> to
remedy the problem. I would like to avoid this solution. I’m sure there is a
way to have my controls behave nicely with event validation.

Any help will be appreciated. Thanks!

--
Steve Loper
Amadeus Consulting

Author
15 Dec 2005 11:01 PM
Phillip Williams
Hi Steve,

Most likely, you have a control (e.g. a textbox control that rendered an
HTML input object) that holds HTML markup or JavaScript in it (your custom
code) that is being posted back.  The EnableEventValidation setting prevents
a malicious user from manipulating the PostBack script to send arbitrary post
events to server controls.  It attempts to verify that any script posted back
was created by the ASP.NET controls that were on the page before the PostBack
happened.

To solve the problem, avoid creating custom objects that PostBack scripts to
the server.
Show quoteHide quote
"Amadeus Consulting" wrote:

> I am developing a control in ASP.NET 2.0 that is derived from GridView. This
> control handles paging on its own and thus renders custom paging buttons. It
> also add some other functionality to the GridView by overriding Render() and
> rendering other controls alongside the GridView’s HTML.
>
> When I click one of the pager buttons (of type ImageButton), I receive the
> following error:
>
> 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.
>
>
> I have searched for other people that have encountered this error, and the
> common suggestion is to specify <pages enableEventValidation=”false” /> to
> remedy the problem. I would like to avoid this solution. I’m sure there is a
> way to have my controls behave nicely with event validation.
>
> Any help will be appreciated. Thanks!
>
> --
> Steve Loper
> Amadeus Consulting
Author
16 Dec 2005 2:38 AM
Steven Cheng[MSFT]
Thanks for Phillip's inputs.

Hi Steve,

I agree with Phillip, the ASP.NET 2.0 by default will enable valiation to
the clientside postback script and the submit form fields, it ensure that
all the post back script and form fields are generated by the Page's script
interface (Page.ClientScripts.xxxx) or the Page's Control structure.....   

So I think your custom webcontrol should be a Rendering control(put the
html output code in Render method) rather than a composite control (using
CreateChildControls to construct control structure....) or you've manually
output some client scripts, yes?

If so, my suggestion is try best to use Composite control instead of
rendering control and always use the Page's script interface to generate
scirpts....(e.g:   ClientScript.GetPostBackEventReference  .......) , and
makesure all the HtmlForm's <input ..... > elements are created through
Control instance rather than rendering through  Response.Write("<input
.......") ....

#Creating Custom Web Controls with ASP.NET 2.0
http://msdn.microsoft.com/library/en-us/dnvs05/html/custwebcon.asp?frame=tru
e

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)







--------------------
| Thread-Topic: =?Utf-8?Q?Custom_GridView_Control_=E2=80=93_Postba?=
|     =?Utf-8?Q?ck_Problems?=
| thread-index: AcYBy2v9mJ7Av0jdRqCyYcOKxQvDfA==
| X-WBNR-Posting-Host: 64.253.156.46
| From: "=?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?="
<Phillip.Willi***@webswapp.com>
Show quoteHide quote
| References:  <7867E55F-4456-45C9-B832-B72F1D1E8***@microsoft.com>
| Subject: =?Utf-8?Q?RE:_Custom_GridView_Control_=E2=80=93_Po?=
|     =?Utf-8?Q?stback_Problems?=
| Date: Thu, 15 Dec 2005 15:01:02 -0800
| Lines: 48
| Message-ID: <A1146B99-D7E9-4604-9A7D-C75B25641***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 8bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31824
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Hi Steve,
|
| Most likely, you have a control (e.g. a textbox control that rendered an
| HTML input object) that holds HTML markup or JavaScript in it (your
custom
| code) that is being posted back.  The EnableEventValidation setting
prevents
| a malicious user from manipulating the PostBack script to send arbitrary
post
| events to server controls.  It attempts to verify that any script posted
back
| was created by the ASP.NET controls that were on the page before the
PostBack
| happened.
|
| To solve the problem, avoid creating custom objects that PostBack scripts
to
| the server.
| --
| HTH,
| Phillip Williams
| http://www.societopia.net
| http://www.webswapp.com
|
|
| "Amadeus Consulting" wrote:
|
| > I am developing a control in ASP.NET 2.0 that is derived from GridView.
This
| > control handles paging on its own and thus renders custom paging
buttons. It
| > also add some other functionality to the GridView by overriding
Render() and
| > rendering other controls alongside the GridView’s HTML.
| >
| > When I click one of the pager buttons (of type ImageButton), I receive
the
| > following error:
| >
| > 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.
| >
| >
| > I have searched for other people that have encountered this error, and
the
| > common suggestion is to specify <pages enableEventValidation=”
false�/> to
| > remedy the problem. I would like to avoid this solution. I’m sure
there is a
Show quoteHide quote
| > way to have my controls behave nicely with event validation.
| >
| > Any help will be appreciated. Thanks!
| >
| > --
| > Steve Loper
| > Amadeus Consulting
|
Author
19 Dec 2005 3:50 PM
Amadeus Consulting
Steven,

Thanks for the response. We have done what you suggested (created the
composite control), and that works for the most part.

Most of what we are tring to do is display some customs via the
PagerTemplate. This is now working very well when there is more than one page
of data. If there is only one page of data, the PagerTemplate is not
displayed.  This appears to be the default behaviour of the GridView control.
Is there any way to force the GridView control to display the PagerTemplate
when there is only a single page of data?

Thanks,
--
Steve Loper
Amadeus Consulting


Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Thanks for Phillip's inputs.
>
> Hi Steve,
>
> I agree with Phillip, the ASP.NET 2.0 by default will enable valiation to
> the clientside postback script and the submit form fields, it ensure that
> all the post back script and form fields are generated by the Page's script
> interface (Page.ClientScripts.xxxx) or the Page's Control structure.....   
>
> So I think your custom webcontrol should be a Rendering control(put the
> html output code in Render method) rather than a composite control (using
> CreateChildControls to construct control structure....) or you've manually
> output some client scripts, yes?
>
> If so, my suggestion is try best to use Composite control instead of
> rendering control and always use the Page's script interface to generate
> scirpts....(e.g:   ClientScript.GetPostBackEventReference  .......) , and
> makesure all the HtmlForm's <input ..... > elements are created through
> Control instance rather than rendering through  Response.Write("<input
> .......") ....
>
> #Creating Custom Web Controls with ASP.NET 2.0
> http://msdn.microsoft.com/library/en-us/dnvs05/html/custwebcon.asp?frame=tru
> e
>
> Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
>
>
>
>
Author
20 Dec 2005 3:31 AM
Steven Cheng[MSFT]
Thanks for your response Steve,

As for the GridView's pager, based on my research, this is a fixed behavior
which is defined in the GridView's rendering part, so when there is only
one page of data, there won't display the Pager , even if we use custom
Pager Template......

Currently what I can get is put the GridView into an HTML table which has
two row, and put a seprate sub table (our pager ) in the second table
row....  We can use the GridView's PreRender event to determine the page
count, if page count is 1, we'll need to make the external pager element
visible, elsewise, leave it invisible..... 

In addition, if you're using Template Pager... (define your own pager
template....), we can use the following code in GridView's Prender event to
make the pager row visible:

protected void GridView1_PreRender(object sender, EventArgs e)
    {
        if (GridView1.PageCount == 1)
        { int count = GridView1.Controls[0].Controls.Count;
               GridView1.Controls[0].Controls[count - 1].Visible= true;
      }
}

the index I used is got from the page's output Trace... Anyway, this is
somewhat depend on the underlying implementation of the GridView , so we're
not recommended to use such means...

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: =?Utf-8?Q?RE:_Custom_GridView_Control_=E2=80=93_Po?=
|     =?Utf-8?Q?stback_Problems?=
| thread-index: AcYEs997kMv0c9+URgmcyEyF5PLOJQ==
| X-WBNR-Posting-Host: 65.103.98.1
| From: =?Utf-8?B?QW1hZGV1cyBDb25zdWx0aW5n?= <Amadeus@community.nospam>
| References:  <7867E55F-4456-45C9-B832-B72F1D1E8***@microsoft.com>
<A1146B99-D7E9-4604-9A7D-C75B25641***@microsoft.com>
<vsGrYneAGHA.***@TK2MSFTNGXA02.phx.gbl>
Show quoteHide quote
| Subject: =?Utf-8?Q?RE:_RE:_Custom_GridView_Control_?=
|     =?Utf-8?Q?=E2=80=93_Postback_Problems?=
| Date: Mon, 19 Dec 2005 07:50:02 -0800
| Lines: 59
| Message-ID: <69C80849-2EB3-4025-BA23-427EBE821***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31893
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Steven,
|
| Thanks for the response. We have done what you suggested (created the
| composite control), and that works for the most part.
|
| Most of what we are tring to do is display some customs via the
| PagerTemplate. This is now working very well when there is more than one
page
| of data. If there is only one page of data, the PagerTemplate is not
| displayed.  This appears to be the default behaviour of the GridView
control.
|  Is there any way to force the GridView control to display the
PagerTemplate
| when there is only a single page of data?
|
| Thanks,
| --
| Steve Loper
| Amadeus Consulting
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Thanks for Phillip's inputs.
| >
| > Hi Steve,
| >
| > I agree with Phillip, the ASP.NET 2.0 by default will enable valiation
to
| > the clientside postback script and the submit form fields, it ensure
that
| > all the post back script and form fields are generated by the Page's
script
| > interface (Page.ClientScripts.xxxx) or the Page's Control
structure.....   
Show quoteHide quote
| >
| > So I think your custom webcontrol should be a Rendering control(put the
| > html output code in Render method) rather than a composite control
(using
| > CreateChildControls to construct control structure....) or you've
manually
| > output some client scripts, yes?
| >
| > If so, my suggestion is try best to use Composite control instead of
| > rendering control and always use the Page's script interface to
generate
| > scirpts....(e.g:   ClientScript.GetPostBackEventReference  .......) ,
and
| > makesure all the HtmlForm's <input ..... > elements are created through
| > Control instance rather than rendering through  Response.Write("<input
| > .......") ....
| >
| > #Creating Custom Web Controls with ASP.NET 2.0
| >
http://msdn.microsoft.com/library/en-us/dnvs05/html/custwebcon.asp?frame=tru
Show quoteHide quote
| > e
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| >
| >
| >
| >
| >
|
|
Author
20 Dec 2005 6:31 PM
Amadeus Consulting
Steven,

A slight modification to your PreRender handler makes it (I think) something
you could recommend:

            if (GridView1.PageCount == 1)
            {
                GridView1.TopPagerRow.Visible = true;
                GridView1.BottomPagerRow.Visible = true;
            }

I don't think this is dependant on the underlying implementation, and this
does work even when using Template Pager.

Thanks for your help.

--
Steve Loper
Amadeus Consulting


Show quoteHide quote
"Steven Cheng[MSFT]" wrote:

> Thanks for your response Steve,
>
> As for the GridView's pager, based on my research, this is a fixed behavior
> which is defined in the GridView's rendering part, so when there is only
> one page of data, there won't display the Pager , even if we use custom
> Pager Template......
>
> Currently what I can get is put the GridView into an HTML table which has
> two row, and put a seprate sub table (our pager ) in the second table
> row....  We can use the GridView's PreRender event to determine the page
> count, if page count is 1, we'll need to make the external pager element
> visible, elsewise, leave it invisible..... 
>
> In addition, if you're using Template Pager... (define your own pager
> template....), we can use the following code in GridView's Prender event to
> make the pager row visible:
>
>  protected void GridView1_PreRender(object sender, EventArgs e)
>     {
>         if (GridView1.PageCount == 1)
>         { int count = GridView1.Controls[0].Controls.Count;
>                GridView1.Controls[0].Controls[count - 1].Visible= true;
>       }
> }
>
> the index I used is got from the page's output Trace... Anyway, this is
> somewhat depend on the underlying implementation of the GridView , so we're
> not recommended to use such means...
>
> Thanks,
>
> Steven Cheng
> Microsoft Online Support
>
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
> --------------------
> | Thread-Topic: =?Utf-8?Q?RE:_Custom_GridView_Control_=E2=80=93_Po?=
> |     =?Utf-8?Q?stback_Problems?=
> | thread-index: AcYEs997kMv0c9+URgmcyEyF5PLOJQ==
> | X-WBNR-Posting-Host: 65.103.98.1
> | From: =?Utf-8?B?QW1hZGV1cyBDb25zdWx0aW5n?= <Amadeus@community.nospam>
> | References:  <7867E55F-4456-45C9-B832-B72F1D1E8***@microsoft.com>
> <A1146B99-D7E9-4604-9A7D-C75B25641***@microsoft.com>
> <vsGrYneAGHA.***@TK2MSFTNGXA02.phx.gbl>
> | Subject: =?Utf-8?Q?RE:_RE:_Custom_GridView_Control_?=
> |     =?Utf-8?Q?=E2=80=93_Postback_Problems?=
> | Date: Mon, 19 Dec 2005 07:50:02 -0800
> | Lines: 59
> | Message-ID: <69C80849-2EB3-4025-BA23-427EBE821***@microsoft.com>
> | MIME-Version: 1.0
> | Content-Type: text/plain;
> |     charset="Utf-8"
> | Content-Transfer-Encoding: 7bit
> | X-Newsreader: Microsoft CDO for Windows 2000
> | Content-Class: urn:content-classes:message
> | Importance: normal
> | Priority: normal
> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
> | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
> | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
> | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
> | Xref: TK2MSFTNGXA02.phx.gbl
> microsoft.public.dotnet.framework.aspnet.webcontrols:31893
> | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
> |
> | Steven,
> |
> | Thanks for the response. We have done what you suggested (created the
> | composite control), and that works for the most part.
> |
> | Most of what we are tring to do is display some customs via the
> | PagerTemplate. This is now working very well when there is more than one
> page
> | of data. If there is only one page of data, the PagerTemplate is not
> | displayed.  This appears to be the default behaviour of the GridView
> control.
> |  Is there any way to force the GridView control to display the
> PagerTemplate
> | when there is only a single page of data?
> |
> | Thanks,
> | --
> | Steve Loper
> | Amadeus Consulting
> |
> |
> | "Steven Cheng[MSFT]" wrote:
> |
> | > Thanks for Phillip's inputs.
> | >
> | > Hi Steve,
> | >
> | > I agree with Phillip, the ASP.NET 2.0 by default will enable valiation
> to
> | > the clientside postback script and the submit form fields, it ensure
> that
> | > all the post back script and form fields are generated by the Page's
> script
> | > interface (Page.ClientScripts.xxxx) or the Page's Control
> structure.....   
> | >
> | > So I think your custom webcontrol should be a Rendering control(put the
> | > html output code in Render method) rather than a composite control
> (using
> | > CreateChildControls to construct control structure....) or you've
> manually
> | > output some client scripts, yes?
> | >
> | > If so, my suggestion is try best to use Composite control instead of
> | > rendering control and always use the Page's script interface to
> generate
> | > scirpts....(e.g:   ClientScript.GetPostBackEventReference  .......) ,
> and
> | > makesure all the HtmlForm's <input ..... > elements are created through
> | > Control instance rather than rendering through  Response.Write("<input
> | > .......") ....
> | >
> | > #Creating Custom Web Controls with ASP.NET 2.0
> | >
> http://msdn.microsoft.com/library/en-us/dnvs05/html/custwebcon.asp?frame=tru
> | > e
> | >
> | > Thanks,
> | >
> | > Steven Cheng
> | > Microsoft Online Support
> | >
> | > Get Secure! www.microsoft.com/security
> | > (This posting is provided "AS IS", with no warranties, and confers no
> | > rights.)
> | >
> | >
> | >
> | >
> | >
> |
> |
>
>
Author
21 Dec 2005 6:50 AM
Steven Cheng[MSFT]
Thanks for your response Steve,

yes, the  GridView.TopPagerRow.Visible or GridView.BottomPagerRow.Visible
looks better :-).
And when using Template Pager, that'll help (manually set the Footer 's
visible to true...).  Also, this does depend on the underlying implemention
of hte GridView's pager, the GridView's createChildControls function will
set the pager's visible to false when the pageCount == 1...

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



--------------------
| Thread-Topic: =?Utf-8?Q?RE:_RE:_Custom_GridView_Control_?=
|     =?Utf-8?Q?=E2=80=93_Postback_Problems?=
| thread-index: AcYFk4fwDZa93m06Qsie62e5+zopoA==
| X-WBNR-Posting-Host: 65.103.98.1
| From: =?Utf-8?B?QW1hZGV1cyBDb25zdWx0aW5n?= <Amadeus@community.nospam>
| References:  <7867E55F-4456-45C9-B832-B72F1D1E8***@microsoft.com>
<A1146B99-D7E9-4604-9A7D-C75B25641***@microsoft.com>
<vsGrYneAGHA.***@TK2MSFTNGXA02.phx.gbl>
<69C80849-2EB3-4025-BA23-427EBE821***@microsoft.com>
<gAYmWXRBGHA.2***@TK2MSFTNGXA02.phx.gbl>
Show quoteHide quote
| Subject: =?Utf-8?Q?RE:_RE:_RE:_Custom_GridView_Cont?=
|     =?Utf-8?Q?rol_=E2=80=93_Postback_Problems?=
| Date: Tue, 20 Dec 2005 10:31:02 -0800
| Lines: 164
| Message-ID: <E3E29DDE-D7B7-4818-B4DD-492711946***@microsoft.com>
| MIME-Version: 1.0
| Content-Type: text/plain;
|     charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:31948
Show quoteHide quote
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Steven,
|
| A slight modification to your PreRender handler makes it (I think)
something
| you could recommend:
|
|             if (GridView1.PageCount == 1)
|             {
|                 GridView1.TopPagerRow.Visible = true;
|                 GridView1.BottomPagerRow.Visible = true;
|             }
|
| I don't think this is dependant on the underlying implementation, and
this
| does work even when using Template Pager.
|
| Thanks for your help.
|
| --
| Steve Loper
| Amadeus Consulting
|
|
| "Steven Cheng[MSFT]" wrote:
|
| > Thanks for your response Steve,
| >
| > As for the GridView's pager, based on my research, this is a fixed
behavior
| > which is defined in the GridView's rendering part, so when there is
only
| > one page of data, there won't display the Pager , even if we use custom
| > Pager Template......
| >
| > Currently what I can get is put the GridView into an HTML table which
has
| > two row, and put a seprate sub table (our pager ) in the second table
| > row....  We can use the GridView's PreRender event to determine the
page
| > count, if page count is 1, we'll need to make the external pager
element
| > visible, elsewise, leave it invisible..... 
| >
| > In addition, if you're using Template Pager... (define your own pager
| > template....), we can use the following code in GridView's Prender
event to
| > make the pager row visible:
| >
| >  protected void GridView1_PreRender(object sender, EventArgs e)
| >     {
| >         if (GridView1.PageCount == 1)
| >         { int count = GridView1.Controls[0].Controls.Count;
| >                GridView1.Controls[0].Controls[count - 1].Visible= true;
| >       }
| > }
| >
| > the index I used is got from the page's output Trace... Anyway, this is
| > somewhat depend on the underlying implementation of the GridView , so
we're
| > not recommended to use such means...
| >
| > Thanks,
| >
| > Steven Cheng
| > Microsoft Online Support
| >
| > Get Secure! www.microsoft.com/security
| > (This posting is provided "AS IS", with no warranties, and confers no
| > rights.)
| > --------------------
| > | Thread-Topic: =?Utf-8?Q?RE:_Custom_GridView_Control_=E2=80=93_Po?=
| > |     =?Utf-8?Q?stback_Problems?=
| > | thread-index: AcYEs997kMv0c9+URgmcyEyF5PLOJQ==
| > | X-WBNR-Posting-Host: 65.103.98.1
| > | From: =?Utf-8?B?QW1hZGV1cyBDb25zdWx0aW5n?= <Amadeus@community.nospam>
| > | References:  <7867E55F-4456-45C9-B832-B72F1D1E8***@microsoft.com>
| > <A1146B99-D7E9-4604-9A7D-C75B25641***@microsoft.com>
| > <vsGrYneAGHA.***@TK2MSFTNGXA02.phx.gbl>
| > | Subject: =?Utf-8?Q?RE:_RE:_Custom_GridView_Control_?=
| > |     =?Utf-8?Q?=E2=80=93_Postback_Problems?=
| > | Date: Mon, 19 Dec 2005 07:50:02 -0800
| > | Lines: 59
| > | Message-ID: <69C80849-2EB3-4025-BA23-427EBE821***@microsoft.com>
| > | MIME-Version: 1.0
| > | Content-Type: text/plain;
| > |     charset="Utf-8"
| > | Content-Transfer-Encoding: 7bit
| > | X-Newsreader: Microsoft CDO for Windows 2000
| > | Content-Class: urn:content-classes:message
| > | Importance: normal
| > | Priority: normal
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| > | NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| > | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGXA03.phx.gbl
| > | Xref: TK2MSFTNGXA02.phx.gbl
| > microsoft.public.dotnet.framework.aspnet.webcontrols:31893
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
| > |
| > | Steven,
| > |
| > | Thanks for the response. We have done what you suggested (created the
| > | composite control), and that works for the most part.
| > |
| > | Most of what we are tring to do is display some customs via the
| > | PagerTemplate. This is now working very well when there is more than
one
| > page
| > | of data. If there is only one page of data, the PagerTemplate is not
| > | displayed.  This appears to be the default behaviour of the GridView
| > control.
| > |  Is there any way to force the GridView control to display the
| > PagerTemplate
| > | when there is only a single page of data?
| > |
| > | Thanks,
| > | --
| > | Steve Loper
| > | Amadeus Consulting
| > |
| > |
| > | "Steven Cheng[MSFT]" wrote:
| > |
| > | > Thanks for Phillip's inputs.
| > | >
| > | > Hi Steve,
| > | >
| > | > I agree with Phillip, the ASP.NET 2.0 by default will enable
valiation
| > to
| > | > the clientside postback script and the submit form fields, it
ensure
| > that
| > | > all the post back script and form fields are generated by the
Page's
| > script
| > | > interface (Page.ClientScripts.xxxx) or the Page's Control
| > structure.....   
| > | >
| > | > So I think your custom webcontrol should be a Rendering control(put
the
| > | > html output code in Render method) rather than a composite control
| > (using
| > | > CreateChildControls to construct control structure....) or you've
| > manually
| > | > output some client scripts, yes?
| > | >
| > | > If so, my suggestion is try best to use Composite control instead
of
| > | > rendering control and always use the Page's script interface to
| > generate
| > | > scirpts....(e.g:   ClientScript.GetPostBackEventReference  .......)
,
| > and
| > | > makesure all the HtmlForm's <input ..... > elements are created
through
| > | > Control instance rather than rendering through 
Response.Write("<input
| > | > .......") ....
| > | >
| > | > #Creating Custom Web Controls with ASP.NET 2.0
| > | >
| >
http://msdn.microsoft.com/library/en-us/dnvs05/html/custwebcon.asp?frame=tru
Show quoteHide quote
| > | > e
| > | >
| > | > Thanks,
| > | >
| > | > Steven Cheng
| > | > Microsoft Online Support
| > | >
| > | > Get Secure! www.microsoft.com/security
| > | > (This posting is provided "AS IS", with no warranties, and confers
no
| > | > rights.)
| > | >
| > | >
| > | >
| > | >
| > | >
| > |
| > |
| >
| >
|