473,385 Members | 1,570 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,385 software developers and data experts.

problem with PostBackUrl

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.FindControl("DataList1")
im = dl.Items(0).FindControl("ImageButton1")
If User.Identity.IsAuthenticated 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
Jan 8 '07 #1
1 4754

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.FindControl("DataList1")
im = dl.Items(0).FindControl("ImageButton1")
If User.Identity.IsAuthenticated 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:ImageButton ID="im" runat="server" PostBackUrl='<%#
GetUrl(Eval("ProdNR")) %>'/>

code:
Protected Function GetUrl(ByVal ProdNR As Object)
If User.Identity.IsAuthenticated Then
Return String.Format("~/prodItem.aspx?ProdNR={0}", ProdNR)
Else
Return "~/log.aspx"
End If
End Function

Maybe it helps.

Jan 9 '07 #2

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

Similar topics

6
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...
1
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...
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" ...
2
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...
1
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.
1
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...
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: 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...
4
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.