Help please.
I have a list of items on my page, alongside each of which i have a
DELETE imagebutton. There can be from 0 to 6 items in the list and they
are placed in a table which cannot be dynamically generated, therefore i
have 6 imagebuttons (for DELETE) and 6 labels (for item name) placed in
the table. There is a string array labelText[6] such that i have
label0.Text=labelText[0];
label1.Text=labelText[1];
etc.
and boolean array buttonvisible[6] such that
button0.Visible=buttonVisible[0];
etc.
I would like each imagebutton to call the same function but somehow pass
a parameter to indicate which item should be deleted.
I could then on postback
1) call the function and delete appropriate item from the list -
labelText[button_no_pressed]="";
and
2) make that delete button invisible
buttonVisible[button_no_pressed]=false;
by using the passed parameter(button_no_pressed=0, button_no_pressed=1
etc)
Can I do this by using onCommand , CommandName and CommandArgument which
i don't really understand yet?OnCommand is usually used for this kind of thing on a DataList or in a grid
where it would do what you suggest, however I dont think you can use that as
you said your grid is not/ can not be dynamicly created.
You might try having each of the buttons individual events calling the same
routine with a parameter.
"tony collier" <melakka@.hotmail.com> wrote in message
news:Xns948692ECB3D41melakkahotmailcom@.140.99.99.1 30...
> Help please.
> I have a list of items on my page, alongside each of which i have a
> DELETE imagebutton. There can be from 0 to 6 items in the list and they
> are placed in a table which cannot be dynamically generated, therefore i
> have 6 imagebuttons (for DELETE) and 6 labels (for item name) placed in
> the table. There is a string array labelText[6] such that i have
> label0.Text=labelText[0];
> label1.Text=labelText[1];
> etc.
> and boolean array buttonvisible[6] such that
> button0.Visible=buttonVisible[0];
> etc.
>
> I would like each imagebutton to call the same function but somehow pass
> a parameter to indicate which item should be deleted.
> I could then on postback
> 1) call the function and delete appropriate item from the list -
> labelText[button_no_pressed]="";
> and
> 2) make that delete button invisible
> buttonVisible[button_no_pressed]=false;
>
> by using the passed parameter(button_no_pressed=0, button_no_pressed=1
> etc)
>
> Can I do this by using onCommand , CommandName and CommandArgument which
> i don't really understand yet?
"Felbrigg" <someone@.microsoft.com> wrote in
news:O#eW1U$6DHA.2656@.TK2MSFTNGP11.phx.gbl:
> OnCommand is usually used for this kind of thing on a DataList or in a
> grid where it would do what you suggest, however I dont think you can
> use that as you said your grid is not/ can not be dynamicly created.
> You might try having each of the buttons individual events calling the
> same routine with a parameter.
>
> "tony collier" <melakka@.hotmail.com> wrote in message
> news:Xns948692ECB3D41melakkahotmailcom@.140.99.99.1 30...
>> Help please.
>>
>> I have a list of items on my page, alongside each of which i have a
>> DELETE imagebutton. There can be from 0 to 6 items in the list and
>> they are placed in a table which cannot be dynamically generated,
>> therefore i have 6 imagebuttons (for DELETE) and 6 labels (for item
>> name) placed in the table. There is a string array labelText[6] such
>> that i have
>>
>> label0.Text=labelText[0];
>> label1.Text=labelText[1];
>> etc.
>>
>> and boolean array buttonvisible[6] such that
>>
>> button0.Visible=buttonVisible[0];
>> etc.
>>
>>
>> I would like each imagebutton to call the same function but somehow
>> pass a parameter to indicate which item should be deleted.
>>
>> I could then on postback
>>
>> 1) call the function and delete appropriate item from the list -
>>
>> labelText[button_no_pressed]="";
>>
>> and
>>
>> 2) make that delete button invisible
>>
>> buttonVisible[button_no_pressed]=false;
>>
>>
>> by using the passed parameter(button_no_pressed=0,
>> button_no_pressed=1 etc)
>>
>>
>> Can I do this by using onCommand , CommandName and CommandArgument
>> which i don't really understand yet?
that is what i want to do - but how . i can't pass a parameter with
onclick.
tony collier <melakka@.hotmail.com> wrote in
news:Xns9486AEA7DFFEmelakkahotmailcom@.140.99.99.13 0:
> "Felbrigg" <someone@.microsoft.com> wrote in
> news:O#eW1U$6DHA.2656@.TK2MSFTNGP11.phx.gbl:
>> OnCommand is usually used for this kind of thing on a DataList or in a
>> grid where it would do what you suggest, however I dont think you can
>> use that as you said your grid is not/ can not be dynamicly created.
>>
>> You might try having each of the buttons individual events calling the
>> same routine with a parameter.
>>
>>
>> "tony collier" <melakka@.hotmail.com> wrote in message
>> news:Xns948692ECB3D41melakkahotmailcom@.140.99.99.1 30...
>>> Help please.
>>>
>>> I have a list of items on my page, alongside each of which i have a
>>> DELETE imagebutton. There can be from 0 to 6 items in the list and
>>> they are placed in a table which cannot be dynamically generated,
>>> therefore i have 6 imagebuttons (for DELETE) and 6 labels (for item
>>> name) placed in the table. There is a string array labelText[6] such
>>> that i have
>>>
>>> label0.Text=labelText[0];
>>> label1.Text=labelText[1];
>>> etc.
>>>
>>> and boolean array buttonvisible[6] such that
>>>
>>> button0.Visible=buttonVisible[0];
>>> etc.
>>>
>>>
>>> I would like each imagebutton to call the same function but somehow
>>> pass a parameter to indicate which item should be deleted.
>>>
>>> I could then on postback
>>>
>>> 1) call the function and delete appropriate item from the list -
>>>
>>> labelText[button_no_pressed]="";
>>>
>>> and
>>>
>>> 2) make that delete button invisible
>>>
>>> buttonVisible[button_no_pressed]=false;
>>>
>>>
>>> by using the passed parameter(button_no_pressed=0,
>>> button_no_pressed=1 etc)
>>>
>>>
>>> Can I do this by using onCommand , CommandName and CommandArgument
>>> which i don't really understand yet?
>>
>>
>>
> that is what i want to do - but how . i can't pass a parameter with
> onclick.
OK - this works:
void submit ( Object sender, CommandEventArgs e )
{
Response.Write("parameter is "+e.CommandName;
}
......
<asp:ImageButton onCommand="submit" ImageUrl="whatever.gif"
runat="server" CommandName="0" /
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment