473,791 Members | 3,015 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Fi ndControl() 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********@hotm ail.com
http://www.nathansokalski.com/
Aug 19 '08 #1
4 4128
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*******@kyle davidgroup.comw rote in message
news:uK******** ******@TK2MSFTN GP02.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.Fi ndControl()
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********@hotm ail.com
http://www.nathansokalski.com/

Aug 19 '08 #2
"Nathan Sokalski" <ns*******@kyle davidgroup.comw rote in message
news:uK******** ******@TK2MSFTN GP02.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.Fi ndControl()
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********@hotm ail.com
http://www.nathansokalski.com/

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

Any postback has 2 arguments...
function __doPostBack(ev entTarget, 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="__doPostB ack('<%#LinkBut ton1.UniqueID%> ','<%#Eval(reco rdID)%>')">Clic k
here</a>

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

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.My Property 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********@hotm ail.com
http://www.nathansokalski.com/

"George" <no*****@comcas t.netwrote in message
news:%2******** **********@TK2M SFTNGP05.phx.gb l...
"Nathan Sokalski" <ns*******@kyle davidgroup.comw rote in message
news:uK******** ******@TK2MSFTN GP02.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********@hotm ail.com
http://www.nathansokalski.com/


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

Any postback has 2 arguments...
function __doPostBack(ev entTarget, 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="__doPostB ack('<%#LinkBut ton1.UniqueID%> ','<%#Eval(reco rdID)%>')">Clic k
here</a>

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

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*******@kyle davidgroup.comw rote:
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.OnClien tClick =
"document.f orms[0].elements['hdnButtonId'].value = this.id"

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

Request["hdnButtonI d"]
Aug 19 '08 #5

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

Similar topics

1
2935
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. I have tried to set the button's visibility in Page_Load (after data binding), but I get a NullReferenceException stating that "Object reference not set to an instance of an object".
1
6429
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 binding it to a repeater control. This repeater control has multiple text boxes and buttons. Can you please tell me how can i do paging in this case ? I'm posting my code below. The problem is that if i click on "AdjustThisAd" button, it opens...
9
4669
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 (item.ToString().IndexOf("__") != 0) { //Response.Write(item + " = " + Request.Form +
4
5351
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" When the second page opened, and tried to get a hidden value on the previous page, I got the following error:
1
1613
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 while saving i want to check if the value in the DDL is not SELECT VALUE, then only it should save those.. so right now my code is private void Item_Created(Object Sender, RepeaterItemEventArgs e) {
0
2095
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 collection as its datasource. However, the panel doesn't update and refresh of page is required (not asynchnonous). Is it possible to have repeater to dynamically update with update panel control? Thanks
2
2675
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 url that looks like the following: PostBackUrl=somepage.aspx?param=<valuewhere <valuecomes from the currently selected item in the list. Thanks, Rob
0
1359
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 happens in rewritten urls. Do not understand why it a happens, hope some one from Microsoft would took a look at it. I spent about a day trying to pinpoint a problem. Finaly did. Here are simple steps to reproduce the problem 1. Create project...
1
8063
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 replace the button with linkbutton every thing works fine and I have my popup dispalying. Is there a reason for the buttons to not function inside the repeater? <asp:Repeater ID="myrep" runat="server" OnItemCommand="myrep_ItemCommand">...
0
9669
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10207
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9029
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7537
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5431
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.