Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > how do I get the value of a post from a hidden field in repeater?

Reply
Thread Tools

how do I get the value of a post from a hidden field in repeater?

 
 
Kevin
Guest
Posts: n/a
 
      02-25-2004
I've got a problem where I need to know the value of a hidden field
inside a repeater once a button is clicked. Ths code inside my
repeater looks like this:

<input id="conf_num" type="hidden" value=<%#
trim(Container.DataItem("confirm_num"))%> name="conf_num"
runat="server" />

<asp:ImageButton ImageUrl="images/send_conf.gif"
OnClick="ConfSend_Click" runat="server" />

Rendered, it looks like this:

<input name="grid3:_ctl1:conf_num" id="grid3__ctl1_conf_num"
type="hidden" value="551059" />

Obviously, I can get the value if I do something like:

Sub ConfSend_Click
ViewState("conf_num") = Request.form("grid3:_ctl1:conf_num")
End Sub

But this doesn't work because to do this right I can't specify the
exact Request.form 'conf_num' value, since that value needs to be
dynamic based on the button the user clicks on. I've tried
everything, I think. Each row in the repeater has its own button...

What happened to the good old days when a hidden field was a hidden
field. The 'grid3:_ctl1:' the rendered repeater adds on is giving me
major problems.

Any ideas?
 
Reply With Quote
 
 
 
 
Raterus
Guest
Posts: n/a
 
      02-25-2004
Look at the commandname/commandargument properties of the imagebutton, you
can set them to anything you want. Then use the onCommand (not onClick)
event of the imagebutton to catch them on the next page. In your handler
e.CommandName and e.CommandArgument would be from the button you clicked.
Doing this you can avoid all the mess of using hidden fields.

Hope this helps,
--Michael

"Kevin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> I've got a problem where I need to know the value of a hidden field
> inside a repeater once a button is clicked. Ths code inside my
> repeater looks like this:
>
> <input id="conf_num" type="hidden" value=<%#
> trim(Container.DataItem("confirm_num"))%> name="conf_num"
> runat="server" />
>
> <asp:ImageButton ImageUrl="images/send_conf.gif"
> OnClick="ConfSend_Click" runat="server" />
>
> Rendered, it looks like this:
>
> <input name="grid3:_ctl1:conf_num" id="grid3__ctl1_conf_num"
> type="hidden" value="551059" />
>
> Obviously, I can get the value if I do something like:
>
> Sub ConfSend_Click
> ViewState("conf_num") = Request.form("grid3:_ctl1:conf_num")
> End Sub
>
> But this doesn't work because to do this right I can't specify the
> exact Request.form 'conf_num' value, since that value needs to be
> dynamic based on the button the user clicks on. I've tried
> everything, I think. Each row in the repeater has its own button...
>
> What happened to the good old days when a hidden field was a hidden
> field. The 'grid3:_ctl1:' the rendered repeater adds on is giving me
> major problems.
>
> Any ideas?



 
Reply With Quote
 
 
 
 
Kevin McGovern
Guest
Posts: n/a
 
      02-25-2004
thanks - worked like a charm.



*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
javascript validation for a not required field, field is onlyrequired if another field has a value jr Javascript 3 07-08-2010 10:33 AM
Populate Hidden field on post back and retrieve value from Hidden Field Rick ASP .Net 3 04-13-2010 05:38 PM
Select box value changes value of hidden field dvwool@ix.netcom.com Javascript 6 04-27-2006 04:38 AM
Pass hidden form field value to another form field to insert in db GavMc ASP General 4 09-22-2005 06:33 PM
Post a hidden field value Rauf ul Hassan Javascript 1 08-20-2003 11:01 AM



Advertisments