Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Retrieve PostBack value of dynamic control (http://www.velocityreviews.com/forums/t773379-retrieve-postback-value-of-dynamic-control.html)

Nick 05-27-2004 05:51 PM

Retrieve PostBack value of dynamic control
 
Hi all
I am hoping that someone would respond to what I am calling a puzzle: obtain the postback value of dynamic hidden control
I am posting a short version of the code, thx for your help

public class AccountSummaryInfo : System.Web.UI.WebControls.WebControl, IPostBackDataHandle
{
#region Constructor/Deconstructo
public AccountSummaryInfo(string StrAccountNum
{
InitializeDataGrid()
BuildControls()
}//End constructo
#endregio

private void BuildControls(
{

protected virtual void Click(object sender, System.EventArgs e)
{
Button btn = (Button)sender
if (btn.CommandName.Equals("Previous")
{ //Code her
_strKey = “Some Value”
Page.Server.Transfer(cPAGENAME,true)

else if (btn.CommandName.Equals("Next")

//Code her
_strKey = “Some Other Value”
Page.Server.Transfer(cPAGENAME,true)

}//End Clic

private void InitializeDataGrid()

}//End DefineDataGrid(
private void GetData(string _strCommand
{
_strKey = “value A
_strPreviousKey = “value 1
}//End GetData(
private void CreateGrid(string[] aList
{
}//End CreateGrid()

protected override void OnPreRender(EventArgs e)

Controls.Add(new LiteralControl("<input type='hidden' name='Key' value='" + _strKey + "'>"))
Controls.Add(new LiteralControl("<input type='hidden' name='PreviousKey' value='" + _strPreviousKey + "'>"))
base.OnPreRender(e)
}//End OnPreRender(
protected override void OnInit(EventArgs e)

GetData(strCommand)
UpdateGrid();
base.OnInit(e)
}//End OnInit(
private void UpdateGrid(


}//End clas
}//end namespac


Robert Koritnik 05-28-2004 07:30 AM

Re: Retrieve PostBack value of dynamic control
 
First of all: CommandName & CommandArgument are posted via Command event,
not Click and because U use those it's best to fire Command event instead of
Click.
Second: Where do you implement IPostBackDataHandler methods?

The best way is to check a sample in MSDN and create your control like it
should be.

If your class implements some interface it doesn't mean that all things get
done automaticly. It only means that you should implement the methods and do
the work by yourself. It just helps you to make correct methods.

So you must implement LoadPostData and if you need to also
RaisePostDataChangedEvent which executes event delegates that MAY be defined
on the page that displays your Custom control.

--
RobertK
{ Clever? No just smart. }

"Nick" <anonymous@discussions.microsoft.com> wrote in message
news:7C14F15A-FAED-47A8-A2F2-A00C44936271@microsoft.com...
> Hi all,
> I am hoping that someone would respond to what I am calling a puzzle:

obtain the postback value of dynamic hidden control.
> I am posting a short version of the code, thx for your help.
>
> public class AccountSummaryInfo : System.Web.UI.WebControls.WebControl,

IPostBackDataHandler
> {
> #region Constructor/Deconstructor
> public AccountSummaryInfo(string StrAccountNum)
> {
> InitializeDataGrid();
> BuildControls();
> }//End constructor
> #endregion
>
> private void BuildControls()
> {
> }
> protected virtual void Click(object sender, System.EventArgs e)
> {
> Button btn = (Button)sender;
> if (btn.CommandName.Equals("Previous"))
> { //Code here
> _strKey = "Some Value";
> Page.Server.Transfer(cPAGENAME,true);
> }
> else if (btn.CommandName.Equals("Next"))
> {
> //Code here
> _strKey = "Some Other Value";
> Page.Server.Transfer(cPAGENAME,true);
> }
> }//End Click
>
> private void InitializeDataGrid()
> {
> }//End DefineDataGrid()
> private void GetData(string _strCommand)
> {
> _strKey = "value A"
> _strPreviousKey = "value 1"
> }//End GetData()
> private void CreateGrid(string[] aList)
> {
> }//End CreateGrid()
>
> protected override void OnPreRender(EventArgs e)
> {
> Controls.Add(new LiteralControl("<input type='hidden' name='Key' value='"

+ _strKey + "'>"));
> Controls.Add(new LiteralControl("<input type='hidden' name='PreviousKey'

value='" + _strPreviousKey + "'>"));
> base.OnPreRender(e);
> }//End OnPreRender()
> protected override void OnInit(EventArgs e)
> {
> GetData(strCommand);
> UpdateGrid();
> base.OnInit(e);
> }//End OnInit()
> private void UpdateGrid()
> {
> }
> }//End class
> }//end namespace
>




Nick 05-29-2004 04:56 PM

Re: Retrieve PostBack value of dynamic control
 
Actually I stripped out the code for IPostBackDataHandler, but it is there
Should'nt the postback event gets fired and post the values as in Framework 1.0
Nick


All times are GMT. The time now is 06:30 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57