473,407 Members | 2,315 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Using PostBackUrl from a Button inside a Repeater

I have a Button that uses the PostBackUrl property which is inside a
Repeater template. When I get to the Page that is being posted to (the one
specified in PostBackUrl), I am having trouble getting access to the Button
that was clicked, because I cannot use the PreviousPage.FindControl() method
since I do not know the id of the Button. What can I do to get access to a
Button that was inside a Repeater? Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Aug 19 '08 #1
4 4102
First thought is to include a some sort of id to PostBackUrl as a query
parameter.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Nathan Sokalski" <ns*******@kyledavidgroup.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I have a Button that uses the PostBackUrl property which is inside a
Repeater template. When I get to the Page that is being posted to (the one
specified in PostBackUrl), I am having trouble getting access to the Button
that was clicked, because I cannot use the PreviousPage.FindControl()
method since I do not know the id of the Button. What can I do to get
access to a Button that was inside a Repeater? Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Aug 19 '08 #2
"Nathan Sokalski" <ns*******@kyledavidgroup.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>I have a Button that uses the PostBackUrl property which is inside a
Repeater template. When I get to the Page that is being posted to (the one
specified in PostBackUrl), I am having trouble getting access to the Button
that was clicked, because I cannot use the PreviousPage.FindControl()
method since I do not know the id of the Button. What can I do to get
access to a Button that was inside a Repeater? Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

The way i do it is a bit manual...

Any postback has 2 arguments...
function __doPostBack(eventTarget, eventArgument)
Unfortunatelly i am not sure how to use evenArgument.

So i would dump on my page (not in the repeater) empty (so it's not visible
on the page) LinkButton (id=LinkButton1) and write OnClick code..
and in DataRepeater will put my own <a
href="__doPostBack('<%#LinkButton1.UniqueID%>','<% #Eval(recordID)%>')">Click
here</a>

The in OnClick code i would get the recordId by
string sId = Request.Form["__EVENTARGUMENT"];

Hope you get an idea..
PS: I wrote of the memory so you might have to modify it a little (instead
of UniqueID use ClientID)....

George.

Aug 19 '08 #3
I'm sure there must be (and if there isn't, there should be) a better way,
but here is what I did:

I added a property to the Page I am posting from, and in the Repeater's
ItemCommand event, I set this property. Then in the Page I am posting to, I
use PreviousPage.MyProperty to get the value I set. It requires adding an
extra property to and implementing the ItemCommand on the posting page, but
at least it makes it simple on the Page you are posting to. I guess it's the
best I'll have for now until someone comes up with a better way.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

"George" <no*****@comcast.netwrote in message
news:%2******************@TK2MSFTNGP05.phx.gbl...
"Nathan Sokalski" <ns*******@kyledavidgroup.comwrote in message
news:uK**************@TK2MSFTNGP02.phx.gbl...
>>I have a Button that uses the PostBackUrl property which is inside a
Repeater template. When I get to the Page that is being posted to (the one
specified in PostBackUrl), I am having trouble getting access to the
Button that was clicked, because I cannot use the
PreviousPage.FindControl() method since I do not know the id of the
Button. What can I do to get access to a Button that was inside a
Repeater? Thanks.

Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/


The way i do it is a bit manual...

Any postback has 2 arguments...
function __doPostBack(eventTarget, eventArgument)
Unfortunatelly i am not sure how to use evenArgument.

So i would dump on my page (not in the repeater) empty (so it's not
visible on the page) LinkButton (id=LinkButton1) and write OnClick code..
and in DataRepeater will put my own <a
href="__doPostBack('<%#LinkButton1.UniqueID%>','<% #Eval(recordID)%>')">Click
here</a>

The in OnClick code i would get the recordId by
string sId = Request.Form["__EVENTARGUMENT"];

Hope you get an idea..
PS: I wrote of the memory so you might have to modify it a little (instead
of UniqueID use ClientID)....

George.

Aug 19 '08 #4
"Nathan Sokalski" <ns*******@kyledavidgroup.comwrote:
What can I do to get access to a Button that was
inside a Repeater? Thanks.
How about putting the ID of the button in a hidden input field via
JavaScript when the button is clicked. The hidden input field will
be
passed on to your new page in the Forms collection. So, the button's
OnClientClick property might look like:

Button1.OnClientClick =
"document.forms[0].elements['hdnButtonId'].value = this.id"

.... and in your postback page, the button's ID will be available,

Request["hdnButtonId"]
Aug 19 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Keith Harris | last post by:
Hi, I have a Repeater control which is bound to a dataset. In the footer of the repeater control, I have a Button whose visibility I want to vary according to the sum of a column being > 0. ...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
9
by: Kevin Blount | last post by:
Here's the code I tried, and found it failed... <form runat="server" method="post" name="CreditCardForm" id="CreditCardForm"> <% foreach (object item in Request.Form) { if...
4
by: sck10 | last post by:
Hello, Can you use the PostBackUrl to post to different sites? I have a page (PostBackURL.aspx' ) on one website (same server) that has a button set to: PostBackURL="http://zone1.web.com" ...
1
by: Nitinkcv | last post by:
Hi, i have my button actually inside a repeater and it validates info from textboxes and ddl inside the repeater.. The prob is that i have "SELECT VALUE" chosen as the default value in my ddl. so...
0
by: =?Utf-8?B?S29uc3RhbnRpbg==?= | last post by:
I have a need to have a repeater inside update panel control which should update dynamically when "Update" button is clicked. I have repeater inside update panel control which takes custom...
2
by: rob | last post by:
Hi, I have a button whose PostBackUrl should include a value from a dropdownlist on the same page. Should I do that in the button's on click event? What I'd like to end up with is a post back...
0
by: George | last post by:
Can not figure out why but if I have button with PostBackUrl specified it breaks UrlRewrite. All buttons stop working. Form submits but corresponded event procedure never called. And it only...
1
by: semomaniz | last post by:
I have a button inside a repeater which is supposed to open a popup when clicked. But when i click on the button my modalpopup does not open. The strange thing is on the code provided below if i...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.