|
Masters,
Maybe a simple question but one I need to ask because I don't know how to handle it. I have an Stored Procedure which returns rows from SQL Server and one of the columns is a bit field.
What I would like to do is to show a thumbnail image in a column if that bit field is set to true and hide the image if false.
Can anyone give me a heads up on how to acheive this. Everything else I have squared away, just this bit is giving me fits.
Thanks in advance for your suggestions.
|
|
|
|
|
You should convert the column into a template field
In the template field insert an image
And in the Bindings, bind the visible property to the BitField
After binding, You should have something like this
<asp:image runat="server" id="img" visible='<%# Eval("BitField") %>' />
If BitField evaluates to true, the image visible will be true, otherwise false
Remember, convert the column to a templatefield
Alexei Rodriguez
|
|
|
|
|
Seems extremly reasonable! I'll give it a shot. Thank you for the reply.
|
|
|
|
|
Believe it or not
It works
You can do many things with template fields
Alexei Rodriguez
|
|
|
|
|
Oh, I wasn't questioning your response at all. You just made it seem very easy and logical. Believe me, I had no idea how to go about it to make any inquiry about any response.
Besides, I won't be able to try it out until the morning..
|
|
|
|
|
Nevermind my last response. I read your's wrong. Sorry about that, I keep forgetting you can't read "tone".
|
|
|
|
|
Hi,
I have a method that retrieves a variable with a click
of a LinkButton. I need to use that variable in an other
method but it becomes null for some reason. I guess that
happens because of the page postback every time and since
i have an initialization command at the beginning of my code
it makes it null again. So should i pass an argument with
the page postback or disable the linkbutton's postback.
And How could i do any of those?
Your help is greatly appreciated.
phivos
|
|
|
|
|
Not sure if you need this variable to persist, but if you do, couldn't you assign it to a Session Variable and retrive it whenever you do a postback?
Just wanted to make a note that I am a newbie and am trying to contribute to this site as others have helped me.
|
|
|
|
|
ffowler wrote: Not sure if you need this variable to persist, but if you do, couldn't you assign it to a Session Variable and retrive it whenever you do a postback?
Have to agree with you FFowler there hold the variable value in session or viewstate but could you elaborate on the sequence of events you are trying to implement?
|
|
|
|
|
I HELPED, I HELPED.....finally!
|
|
|
|
|
Yes exactly, does any of you guys know how to assign it as a Session variable
and then how to retrieve it back?
Thanks a lot!
|
|
|
|
|
Session["Giveitaname"] = value
//if the value you are storing is string i suggest do this
if(!string.IsNullorEmpty(Session["Giveitaname"].toString())
{
newvalue = Session["Giveitaname"].tostring();
}
//otherwise just check if null then cast it accordingly
|
|
|
|
|
Thank's a lot for your post! Works!
|
|
|
|
|
Hello,
When I try to add a web reference in Visual studio 2005.
Below operation do not happen:
A WSE-enabled proxy class is added to the project
I just have two files in the Webreference folder:
wsdl and disco map.
Regards
Pavas
Regards,
Pavas
|
|
|
|
|
Is there a special trick to clearing a javascript cache in IE7?
I have tried deleting all files through IE, deleting the temporary asp.net files, rebooting the machine - it still runs the old code.
If I call the page from another machine running IE6, it runs the new code.
Googling shows up some pretty weird stuff that has not helped...
TIA!!!
|
|
|
|
|
Have you tried holding CTRL+SHIFT on your keyboard while pressing the refresh button at the top?
I hope this helps.
|
|
|
|
|
Ok try selecting tools --> internet options --> settings (under browsing history) --> select the option every time you visit --> set disk size to 8 also you can then click on the advanced tab under security check the box Empty temporary internet files folder every time browser is closed
A pessimist sees the difficulty in every opportunity; an optimist sees the opportunity in every difficulty I am a Optimist
|
|
|
|
|
Thanks for both suggestions - these both work fine for inline javascript, but still does not refresh the external .js file.
|
|
|
|
|
Hello all,
i wrote this code for my catalogue pictures for my shop site,i want become thumbnail my pictures:
Eval("picure_url", "thumb_{0}")
but my pictures become loss when i add Thumb_ to my code
what do i do now?
thank you,
Hoda
modified on Wednesday, April 2, 2008 3:59 PM
|
|
|
|
|
|
Thank you very much for your response.
|
|
|
|
|
Hello,
I am trying to attach a signature with the proxy and trying to do some operation like below:
wse.RequestSoapContext.Security.Tokens.Add (new X509SecurityToken(cert));
X509SecurityToken crtTkn = new X509SecurityToken(cert);
http://www.eggheadcafe.com/articles/20021231.asp
I am not able to see a "RequestSoapContext" under my proxy of webservice...? Could some one please suggest. What I might be missing. I have installed WSE 2.0
Regards,
Pavas
|
|
|
|
|
Hi
Can somebody please help me out. I created a Site that works but the code is directed to an Access Database.
I swopped to SQL Server 2005 and need to alter my code to connect and Select the Username and Password from
SQL Server 2005.
What changes do i need to make?
See Code Below please.
Imports System.Collections.Generic
Partial Class MasterPage
Inherits System.Web.UI.MasterPage
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dlgLogin.Focus()
'Sets connectionstring and checks if user is logged in...................................
DBFunctions.setConnectionString(AccessDataSource1.ConnectionString)
If Not IsPostBack Then
'Page counter code...................................................................
If Application("PageCounter") Is Nothing Then
Application("PageCounter") = 1
Else
Application("PageCounter") += 1
End If
lblCounter.Text = Application("PageCounter")
'Connection........................................................................
If Not Session("Email") Is Nothing Then
LoggedIn()
Else
lblName.Visible = False
End If
End If
End Sub
Public Sub LoggedIn()
lblName.Visible = True
linkEdit.Enabled = True
lbtnLogout.Enabled = True
linkEdit.Visible = True
lbtnLogout.Visible = True
'Rater check for Username...............................................................
Try
Dim checkList As List(Of List(Of String)) = DBFunctions.queryRows("SELECT Username FROM Rater WHERE Email = '" + Session("Email") + "'")
lblName.Text = "Hello, " + checkList(0)(0)
lblName.ForeColor = Drawing.Color.DarkGreen
Catch ex As Exception
End Try
'Company check for Company Name................................................................
Try
Dim checkList2 As List(Of List(Of String)) = DBFunctions.queryRows("SELECT Name FROM Company WHERE Email = '" + Session("Email") + "'")
lblName.Text = "Hello, " + checkList2(0)(0)
lblName.ForeColor = Drawing.Color.Black
Catch ex As Exception
End Try
dlgLogin.Visible = False
linkRater.Visible = False
linkComp.Visible = False
linkPassword.Visible = False
End Sub
'boolean, returns true if login successful, false if not
Private Function authenticate(ByVal uname As String, ByVal password As String) As Boolean
'Rater check for email and password................................................................................
Try
Dim checkList As List(Of List(Of String)) = DBFunctions.queryRows("SELECT COUNT(Email) FROM Rater WHERE Email = '" + uname + "' and Password = '" + password + "'")
If checkList(0)(0) = "1" Then
Return True
End If
Catch ex As Exception
End Try
'Company check for email and password.............................................................................
Try
Dim checkList2 As List(Of List(Of String)) = DBFunctions.queryRows("SELECT COUNT(Email) FROM Company WHERE Email = '" + uname + "' and Password = '" + password + "'")
If checkList2(0)(0) = "1" Then
Return True
End If
Catch ex As Exception
End Try
Return False
End Function
Protected Sub dlgLogin_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles dlgLogin.Authenticate
e.Authenticated = authenticate(dlgLogin.UserName, dlgLogin.Password)
End Sub
Protected Sub lbtnLogout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbtnLogout.Click
dlgLogin.LoginButtonText = "Log In"
lblName.Visible = False
lbtnLogout.Enabled = False
lblName.Text = "Hello, "
Session.Clear()
Session.Abandon()
Session.RemoveAll()
dlgLogin.Enabled = True
Response.Redirect("Default.aspx")
End Sub
Protected Sub dlgLogin_LoggedIn(ByVal sender As Object, ByVal e As System.EventArgs) Handles dlgLogin.LoggedIn
Session("Email") = dlgLogin.UserName
LoggedIn()
End Sub
'For setting Label from other forms
Public Property Header() As String
Get
Return lblName.Text
End Get
Set(ByVal value As String)
lblName.Text = value
End Set
End Property
Protected Sub linkEdit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles linkEdit.Click
If lblName.ForeColor = Drawing.Color.Black Then
Response.Redirect("CompanyRegister.aspx")
Else
Response.Redirect("RaterRegister.aspx")
End If
End Sub
End Class
|
|
|
|
|
Looks like you've encapsulated your database logic well enough that you should only need to update your queryRows method and your setConnectionString method. There isn't any difference in your code that you've posted. Lookup SqlConnection and SqlCommand for a good start on how to rewrite your methods.
Etienne wrote: DBFunctions.queryRows("SELECT COUNT(Email) FROM Company WHERE Email = '" + uname + "' and Password = '" + password + "'")
As an aside, this is really bad practice for any application regardless of wither it's Access or SQL Server.
Instead you should do the following:
<br />
"SELECT COUNT(Email) FROM Company WHERE Email = @email and Password = @password"<br />
If you are using SQL Server pass this to the SqlCommand object. If you're using Access use OleDbCommand. Then regardless of the command object set the value of @email and @password using Parameters collection of the command object you create. You open yourself up to SQL Injection attacks otherwise.
Also, when you're updating data you're open to cross-site scripting attacks (XSS) unless you sanitize the data you get from the user using either Server.UrlEncode or Server.HtmlEncode. like this:
<br />
Dim email As String = Server.HtmlEncode(Request.Form("email"))<br />
<br />
' now you can pass your variable "email" to your SQL command<br />
<br />
<br />
I didn't see any examples of how you're updating data in your code above, but seeing your queries makes me think you aren't sanitizing your inputs either.
Sorry if the code samples don't compile, I haven't used VB in at least 6 years and I've never really used VB.NET.
|
|
|
|
|
Hi, I kind figure out the problem why the FormsAuthentication cookie can't be set, because just after the authentication it brings me back to the same page with the message that my session has been expired.
Lets see my webconfig.
<system.web>
<authentication mode="Forms">
<forms path="BackOffice" loginurl="BackOffice/Default.aspx?state=Timeout" protection="All" timeout="1">
</forms>
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
The state=Timeout is caught to show an alert saying that the session has been timed out
The code that i use just after a successful authentication:
'FormsAuthentication.SetAuthCookie(tbxEmail.Text.Trim, False)
FormsAuthentication.RedirectFromLoginPage(tbxEmail.Text.Trim, True)
Response.Redirect("Home.aspx")
After a successfull authentication I don't get directed to the Home.aspx page.
When i set the following in the webconfig:
<forms path="BackOffice" loginUrl="BackOffice/Default.aspx?state=Timeout" protection="All" timeout="1" cookieless="UseUri">
but than my string changes to something like:
http://localhost:4190/TEST/(F(DkeaiAh5OWpUmiVajjisadVvodQMLp1lpg4yu8pQK_PlxqApl5udnh7iAx1Yi8KhNbLIx6pQkytYVuhnwCj7GmfkbmpD-2IxXSxyilQM5HDrQ9-byppwLdbd_uBxEeSNdo5UNcPd9nxQxW0ZU3o3Sw2))/BackOffice/Home.aspx
What I am doing wrong? How i can use normal cookies zo i don't need to have the UseUri flag?
Thanks
|
|
|
|