Hi,
i created an ImageButton within an ItemTemplate of a datalist (in
shop.aspx). There are two possibilities:
1) when the user is logged and he clicks on an image, he must be
'postbacked' to another file showing that same picture in big size and with
more info..
2) when not logged and clicking on an image, he must be 'postbacked' to the
login page (log.aspx).
So i put the PostBackUrl property in code-behind like this:
Dim dl As DataList
Dim im As ImageButton
dl = form1.FindContr ol("DataList1" )
im = dl.Items(0).Fin dControl("Image Button1")
If User.Identity.I sAuthenticated Then
im.PostBackUrl = "Eval(""ProdNR" ", ""prodItem.aspx ?ProdNR={0}"")"
Else
im.PostBackUrl = "~/log.aspx"
End If
My double problem is:
1)when not logged, if i click on the first image, i'm postbacked to
log.aspx, but clicking on another image: nothing happens
2) when logged, if i click on the first image, i ger the error: "illegal
characters in path', and clicking on another image: same as 1): nothing
happens.
Any help would be appreciated.
Thanks
Chris 1 4777
Chris wrote:
Hi,
i created an ImageButton within an ItemTemplate of a datalist (in
shop.aspx). There are two possibilities:
1) when the user is logged and he clicks on an image, he must be
'postbacked' to another file showing that same picture in big size and with
more info..
2) when not logged and clicking on an image, he must be 'postbacked' to the
login page (log.aspx).
So i put the PostBackUrl property in code-behind like this:
Dim dl As DataList
Dim im As ImageButton
dl = form1.FindContr ol("DataList1" )
im = dl.Items(0).Fin dControl("Image Button1")
If User.Identity.I sAuthenticated Then
im.PostBackUrl = "Eval(""ProdNR" ", ""prodItem.aspx ?ProdNR={0}"")"
Else
im.PostBackUrl = "~/log.aspx"
End If
My double problem is:
1)when not logged, if i click on the first image, i'm postbacked to
log.aspx, but clicking on another image: nothing happens
2) when logged, if i click on the first image, i ger the error: "illegal
characters in path', and clicking on another image: same as 1): nothing
happens.
Any help would be appreciated.
Thanks
Chris
Hi,
It is incorrect syntax of Eval function use.
If you want to change template control at server side:
1.You can do it within OnItemDataBound event: http://msdn2.microsoft.com/en-us/lib...databound.aspx
2.Wrap custom logic in the separate function:
aspx:
<asp:ImageButto n ID="im" runat="server" PostBackUrl='<% #
GetUrl(Eval("Pr odNR")) %>'/>
code:
Protected Function GetUrl(ByVal ProdNR As Object)
If User.Identity.I sAuthenticated Then
Return String.Format(" ~/prodItem.aspx?P rodNR={0}", ProdNR)
Else
Return "~/log.aspx"
End If
End Function
Maybe it helps. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ABC |
last post by:
I write the code as:
<asp:LinkButton ID="LinkButton2" Text='<%# Eval("Title") %>'
PostBackUrl='file://<%# Eval("path") %>' runat="server"></asp:LinkButton>
But It don't work to download or open file when I clicked.
How should I do?
|
by: Sean |
last post by:
The only problem I am having in my case is that I need to programmically fire
the button that has the PostBackURL property on it becuase in some cases I
want to user to be "redirected" to another page and not have to interact with
the page at all.
THANKS!
|
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:
|
by: xeroxero |
last post by:
I have the property "PostBackUrl" set on a LinkButton set to
"~/page.aspx". I tried to change this value in the Page_Load as well
as the Render event to a different page based on some flow/business
logic. Nothing worked.
What is the best way to dynamically define PostBackUrl for a control
in a C# code-behind, and what is the best way to know in the receiving
page which control fired the PostBack event?
|
by: joseph |
last post by:
Hello
Could you help
i want to use postbackurl to a new window, not replace previous page.
i doing something
onclientscript="form1.target='_blank'" postbackurl="~/default2.aspx" is
not work.
| |
by: Jon |
last post by:
Hello all,
I have a LinkButton with the PostBackUrl set, I also have an OnClick
event set.
For some reason, the OnClick event is only hit the second time I click
the LinkButton. If I remove the PostBackUrl attribute it hits it every
time. Why is that?
Thanks,
|
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
|
by: sweatha |
last post by:
Hello Friends
I have designed the form with three dropdownlist boxes named Default.aspx. The first DropDownList box (DropDownList1) is filled with movie names. The second DropDownList box(DropDownList2)is filled with theatre names and the third DropDownList box (DropDownList3) is filled with dates from sql server. In my Second form(Default2.aspx) ,I have called these dropdown boxes selected value from Default.aspx form using query and...
|
by: Nathan Sokalski |
last post by:
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...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |