|
Hi, thanks for responding, your suggestion did not work and it generates two errors.
1) On line Dim _buf as byte() = ctype(cmd.ExecuteScalar(), byte()) , the error
'(' expected is given.
2) On line Response.BinaryWrite(_buf) , the error _buf is not declare is given.
I have tried changing Dim _buf as byte() to Dim _buf() as byte, but that didn't help.
|
|
|
|
|
HI
I am tryin to make a simple session which should pass the verified username accross to the user home page
and display the username in a label
i have the following
Dim uname As String = txtUserName.Text
Session("username") = uname
and i am tryin to catch it using the following
Dim username As String
username = Request.QueryString.Get("username")
lblUsername.Text = username
i have also tried, to no avail
username = ctype(session("username"),string)
Anyone see a problem
boy
|
|
|
|
|
//Dim uname As String = txtUserName.Text
//Session("username") = uname
Check the uname is empty or not.
i think you are trying to use the querystring value to set it in username.
so check whether the username is empty or not.
//Dim username As String
//username = Request.QueryString.Get("username")
//lblUsername.Text = username
IF everything is ok ,then it will surely work.
All The Best
Sathesh Pandian
|
|
|
|
|
username = Request.QueryString.Get("username")
username = Session("username").ToString()
|
|
|
|
|
still no joy
|
|
|
|
|
You can do a simple test like so:
On a test page, in the form load event (or some other event):
Session("username") = "Testing"
Then on any other page in your site, you can do the following.
If Not Session("username") Is Nothing Then
Response.Write(Session("username").ToString())
End If
Because Sessions are objects like most things, you can simply call the ToString() method on the session object, as you know that what you are saving is a string already. I would'nt waist the overhead doing a conversion.
If you still do not get the value from the session object, make sure that sessions are enabled either by your host and/or in your web.config.
Hope this helps
|
|
|
|
|
Hi Guys
I just can't get this stupid session to work
I have tried doin in a seperate method and callin that method from the page_load to no avail
once i log in and set the session variable, it jus goes to the next page and does nothin at all, i have even tried returnin the value in a textbox on the second page and i get nothin.
I get value for the session after i set it, so there must be somthin wrong with my page when it is receivin it
any ideas
<code>
I set my session variable equal to the users username once it has been validated as being a valid login
Sub validateLogin(ByVal cmdString)
'Creates object and sets value equal to return value
Dim validation As Object = cmdString.Parameters("?p_valid").Value
'Validates if users login is valid or invalid
If validation = 0 Then
Label1.Text = ("Your Login is not valid")
Else
Dim uname As String = txtUserName.Text
Session("Loggedin") = "Yes"
Session("username") = uname
MsgBox(Session("username").ToString)
checkGroupStatus()
End If
End Sub
What i want to do is place this value in a label
and it jus does nothin
I have it set to a messagebox in this example
any help would be appreciated
cheers boyindie
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="adminHome.aspx.vb" Inherits="adminHome" Strict="true" %>
<script runat=server >
Sub page_load()
MsgBox("username is:" & Session("username").ToString)
End Sub
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Welcome
<asp:Label runat="server" ID="lblUsername" Visible="true"></asp:Label>
<ul id="navlist">
<!--Navigation menu code-->
<li style="color: black"><a href="adminUserAccounts.aspx">Users </a></li>
<li><a href="">Site Maintenance</a></li>
<li><a href="">Content Manager</a></li>
</ul>
</div>
</form>
</body>
</html>
</code>
|
|
|
|
|
Did you try adding a test value like I described. Then you could step through it line by line checking if the condition(s) are met.
If Not Session("username") Is Nothing Then
Response.Write(Session("username").ToString())
End If
If set a break point on the "If.." you would see if the session variable is "something" and if so, obtain its value.
Are you sure that this will ever equal true:
If Validation Then
This variable is just a raw object, not of boolean type. Maybe you should look at that as well.
Dim validation As Object = cmdString.Parameters("?p_valid").Value
Dim validation As Boolean = Boolean.TryParse(cmdString.Parameters("?p_valid").Value, False)
|
|
|
|
|
It never seems to ever reach the code I tried doing what you said above and it jus does all the page setup but it never runs the code for some annoyin reason, I have placed the code in the page_load
the validation method does work properly, its not a boolean it returns and int, if it is 1 then it sets the users login session to true and takes the users username and passes that into a session. it should then go and check the users privelages and redirect them to the correct home page
could my login session effect my username session being passed?
Any ideas
Cheers Jack
|
|
|
|
|
Dim uname As String = txtUserName.Text
Session("username") = uname
and i am tryin to catch it using the following
Dim username As String
username = Request.QueryString.Get("username")
lblUsername.Text = username
hey are youo want the value of the session variable .. if yes then u do not use QueryString Method
u have to use like
///
Dim username As String
username = Session("username").ToString();
lblUsername.Text = username
|
|
|
|
|
Problem sorted
wasn't importing system.data
|
|
|
|
|
Hi..
How to copy stored procedures from mdb file for a website to another for another website using Visual studio 2005?
I am too late but i will never give up
|
|
|
|
|
The easiest way would be to open SQL Anaylizer and script the stored procedure to file or new window. Then run that script on the other DB.
|
|
|
|
|
doWhileSomething wrote: script the stored procedure to file or new window
Do you mean copying each stored procedue content (open,select all,copy) to the SQL Analyzer then choose save all Queries.Then open the .sql file and copy its contents and run it in the new DB ?.
I am too late but i will never give up
|
|
|
|
|
Actually what I meant was to open SQLA, select your DB, select programmability, stored procedures, then select a given proedure. Right click on that sproc, select "Script Stored Procedure As.." then the "Create To" option. This would then populate either a file or new qWindow with the code to create the procedure. There are other options there as well.
If you need all of them or the entire DB, then you might want to look at other options.
|
|
|
|
|
I got your idea but Iam using Sql 2000 Analyzer where the aspnetDB.mdf file doesn't appear as a database in the local server.Does the Visual Studio 2005 have a SQLAnalyzer or there is a software which I should install?
I am too late but i will never give up
|
|
|
|
|
You can download the free version of management studio express from MS. It works with both 2000 and 2005.
Your version should work too, but I don't believe the ATTACH method was available in 2000. In your case you would need to copy the DB files to the Data directory the SQL will look in.
e.g. C:\Program Files\Microsoft SQL Server\.....
|
|
|
|
|
I have copied the DB files(.mdf) to the data directory but the database didn't appear in the
SQL 2000 Server Enterprise Manager.Then I tried using Attach database but it doesn't work too(I got an error telling me:couldn't find row in sysindexes...).
It seems that the last choice remains to me is downloading management studio express from MS.
I am too late but i will never give up
|
|
|
|
|
I'm retrieving data from the database and try to pass it on to a javascript function so I can process it. I get a javascript error when I try to pass the value.
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim val As String = CType(FormView2.FindControl("ImgList"), HtmlInputHidden).Value
MsgBox(val)
Dim script As String = ""
script = ""
script &= "var str = String(" & val & ");"
script &= "alert(str);"
script &= "setImageArr(" & str & ");"
script &= ""
Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "SetList", script)
End Sub
When I check via MsgBox the right value shows, but it want show in the javascript.
Any suggestions.
Thanks
|
|
|
|
|
The error is right here :
TAK78 wrote: script = ""
script &= "var str = String(" & val & ");"
script &= "alert(str);"
script &= "setImageArr(" & str & ");"
script &= ""
First of all, use a stringbuilder !!
<br />
StringBuilder sbScript = new StringBuilder();<br />
sbScript.Append("<script language='javascript' type='text/javascript'>");<br />
sbScript.Append(Environment.NewLine);<br />
sbScript.Append("alert('");<br />
sbScript.Append(str.Replace("'", "\\'"));<br />
sbScript.Append("')");<br />
sbScript.Append(Environment.NewLine);<br />
scScript.Append(setImageArr('");<br />
sbScript.Append(str);<br />
sbScript.Append(')");<br />
sbScript.Append("</script>");<br />
|
|
|
|
|
TAK78 wrote: I get a javascript error when I try to pass the value.
Standard question #2:
What error message do you get?
TAK78 wrote: script &= "setImageArr(" & str & ");"
As you have no variable named str in your server code, a new empty variable is created. This code will therefore not put any parameter in the Javascript code. You should have Option Explicit in your code to protect you from inadvertently create variables.
You have to put quotes or apostrophes around the string value in the Javascript code. Also you have to encode the value properly, or you will have problems with certain characters.
Dim script As String = _
"<script type=""text/javascript"">" + _
"var str='" + val.Replace("\","\\").Replace("'","\'") + "';" + _
"alert(str);" + _
"setImageArr(str);" + _
"</script>"
---
single minded; short sighted; long gone;
|
|
|
|
|
Thanks a lot works perfect now!!!
So problem was that you have to encode the special characters before you pass it on, right?
Thanks for the help and advice
|
|
|
|
|
And still use a stringbuilder for string manipulation... is works a lot faster :->
|
|
|
|
|
|
Eduard Keilholz wrote: And still use a stringbuilder for string manipulation... is works a lot faster
Not if you write the code as I did, which produces a single call to String.Concat.
---
single minded; short sighted; long gone;
|
|
|
|