|
Please read the forum guidlines. You cros-posted in THREE boards which is a no-no. Give your messages meaningful titles and not 'help me.'
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
Hello
I'm having a go at using web user controls and url rewritting in asp.net 1.1 (vb) and I'm having a problem with urls, here is what I want to do:
1. I want to use one .asx page for all my UI and load user controls depending on what is clicked by user (as a master page would do in .net 2.0)
2. My hyperlink controls' NavigateUrl property have the virtual path for the user control to load (set in the designer)
3. In Application_BeginRequest method I get the virtual path part from the request and use context.rewritepath to my .aspx page with the virtual path as a querystring
MY PROBLEM:
The string in the request.rawurl keeps getting longer every time i click a link. The virtual path keeps getting appended to the url each time.
Please help!! (I'm a newbie in this area)
Thanks
George
Standing on the shoulders of a giant
|
|
|
|
|
1. I want to use one .asx page for all my UI and load user controls depending on what is clicked by user (as a master page would do in .net 2.0)
This is a bit of a misconception, as master pages in 2.0 still use multiple pages, albeit content pages. The content pages are not controls, they are actually pages that basically include the master page.
3. In Application_BeginRequest method I get the virtual path part from the request and use context.rewritepath to my .aspx page with the virtual path as a querystring.
Can you show how your doing this? I would use an http module for this, there are many examples of this on the web.
A snippet would look something like this:
Private Sub Application_BeginRequest( _
ByVal source As Object, _
ByVal e As EventArgs)
Dim application As HttpApplication = CType(source, HttpApplication)
Dim context As HttpContext = application.Context
Dim addressbar As String = context.Request.RawUrl.ToString()
'Do something with the url, db lookup, etc..
context.Response.Redirect("http://www.HERE.com/", True)
End If
|
|
|
|
|
Thanks here is the code:
----------------------------------------------------
Dim sPath As String = Request.Path.ToLower
Dim iStart As Integer = sPath.LastIndexOf("/") + 1
Dim iFirst As Integer = sPath.IndexOf("/", 0) + 1
Dim sPage As String
Dim sVirtualDirectory As String
Dim sPage2 As String
Dim sQS As String = Request.QueryString.ToString
Dim cnfg As New ConfigurationHelper(Request.PhysicalApplicationPath & "Config\config.xml")
Dim sDefaultPageName As String = cnfg.GetString("DefaultPage")
sVirtualDirectory = sPath.Substring(0, sPath.IndexOf("/", 1))
If (sPath.IndexOf(".aspx") - iStart) > 0 Then
sPage = sPath.Substring(iStart, sPath.IndexOf(".aspx") - iStart)
sPage2 = sPath.Substring(0, sPath.IndexOf(".aspx"))
End If
Select Case sPage
Case sDefaultPageName.ToLower
Context.RewritePath(sVirtualDirectory & "/" + sDefaultPageName + ".aspx")
Case Else
Context.RewritePath(sVirtualDirectory & "/" + sDefaultPageName + ".aspx" & "?page=" & sPage2 & "&" & sQS)
End Select
---------------------------------------------------------------------------------------
On the first time the page is loaded it all works fine, but on subsequent clicks on hypelinks in the user controls the rawurl concatinates the path of control
-- modified at 2:51 Friday 20th July, 2007
|
|
|
|
|
Dim sPath As String = Request.Path.ToLower
Dim iStart As Integer = sPath.LastIndexOf("/") + 1
Dim iFirst As Integer = sPath.IndexOf("/", 0) + 1
Dim sPage As String
Dim sVirtualDirectory As String
Dim sPage2 As String
Dim sQS As String = Request.QueryString.ToString
Dim cnfg As New ConfigurationHelper(Request.PhysicalApplicationPath & "Config\config.xml")
Dim sDefaultPageName As String = cnfg.GetString("DefaultPage")
sVirtualDirectory = sPath.Substring(0, sPath.IndexOf("/", 1))
If (sPath.IndexOf(".aspx") - iStart) > 0 Then
sPage = sPath.Substring(iStart, sPath.IndexOf(".aspx") - iStart)
sPage2 = sPath.Substring(0, sPath.IndexOf(".aspx"))
End If
Select Case sPage
Case sDefaultPageName.ToLower
Context.RewritePath(sVirtualDirectory & "/" + sDefaultPageName + ".aspx")
Case Else
Context.RewritePath(sVirtualDirectory & "/" + sDefaultPageName + ".aspx" & "?page=" & sPage2 & "&" & sQS)
End Select
|
|
|
|
|
have you tried stepping through this line by line using the debugger. This would tell you what conditions are being met and which case statements are being used.
How are you links getting their values? Chances are they are getting the wrong value from the get go.
Can you provide two examples of what the links look like? One for the intial load, and another for after you click on a link.
|
|
|
|
|
In the designer I set the NavigateUrl for the HyperLink to "UsrControl/NetworkUI/UC_CategoriesList.aspx" (the .aspx extention is just so it looks as page when user hovers over link in browser).
This is the rawurl which I get in Application_BeginRequest when I click the hyperlink for the first time. "UsrControl/NetworkUI/UC_CategoriesList.aspx" which is fine.
When I click the second time I hit the Case Else part:
Context.RewritePath(sVirtualDirectory & "/" + sDefaultPageName + ".aspx" & "?page=" & sPage2 & "&" & sQS)
at this point the url is now "UsrControl/NetworkUI/UsrControl/NetworkUI/UC_CategoriesList.aspx".
and with subsequent clicks it keeps appending "UsrControl/NetworkUI" to the url.
and all links on the user control have their url changed as well
In the user control Page_load the NavigateUrl for the hyperlink is still set the one I set in Designer
This can be reproduced by creating an asp.net project and add a page. Add a folder and add a user control in the folder,drop a hyperlink on the user control and set the NavigateUrl to something.
rewrite the path (context.rewritepath) to the page in Application_BeginRequest (so you can be able to click more than once)
and check the rawurl every time you click.
Thanks
|
|
|
|
|
Hi,
I am looking for just a plain calendar on the page. I just need to display the days and if a property is booked I must display the day block as another colour. This I havem but the day number have a link. How do I remove the link so that the day number is just plain text?
I am using the asp:Calendar control.
Regards
ma se
|
|
|
|
|
This is what Microsoft help has on marking days as selectable:
VB.net
Protected Sub Calendar1_DayRender(ByVal sender As Object, _
ByVal e As DayRenderEventArgs) Handles Calendar1.DayRender
Dim myAppointment As Date = New Date(2005, 10, 1)
If (e.Day.Date = myAppointment) Then
e.Day.IsSelectable = True
Else
e.Day.IsSelectable = False
End If
End Sub
C#
protected void Calendar1_DayRender(object sender,
DayRenderEventArgs e)
{
DateTime myAppointment = new DateTime(2005, 10, 1);
if (e.Day.Date == myAppointment)
{
e.Day.IsSelectable = true;
}
else
{
e.Day.IsSelectable = false;
}
}
Ben
|
|
|
|
|
Any one know (prefer some sample source code) for below two queries:
a) How I can use FormView (insert Template) in unbound behavior. I want to write my own insert statements rather than using SQLDataSource cmmandname=”insert” etc…
b)I also need to do data validation of formview controls through java script.
Thanks
Amit
|
|
|
|
|
I know this but problems is here i have to hard code control names...
(FormView1.FindControl("TxtFName"))).Text.ToString();
|
|
|
|
|
I have an *extremely* basic question. Much of the code below has been lifted from Scott Hilier's book on MOSS. I have also asked him this question with no response as yet.
When I click on a button in a sharepoint web part, I think it should run the method I associate:
protected override void CreateChildControls()
{
m_button = new Button();
m_button.Text = "Push Me!";
m_button.Click += new EventHandler(m_button_Click);
Controls.Add(m_button);
}
protected override void RenderContents(HtmlTextWriter writer)
{
m_button.RenderControl(writer);
}
void m_button_Click(object sender, EventArgs e)
{
m_report += "Button Click ";
}
...The problem is that "Button Click" is never reached. It does post back, but it does not reach my breakpoint and does not write the text.
Ideas appreciated.
Cheers,
Daaron
|
|
|
|
|
Hi, I get the error message " Name 'parse' is not declared" in the following code.
Try<br />
_con.Open()<br />
Dim _cmd As OdbcCommand = _con.CreateCommand()<br />
_cmd.CommandText = "select Resumes from" + " Contenttbl where id='" + id + "'"
Dim _buf As Byte() = CByte(parse(_cmd.ExecuteScalar()))
Response.BinaryWrite(_buf)<br />
Catch<br />
Finally<br />
<br />
_con.Close()<br />
End Try
Isn't Parse a method name, why would I have to declare it if its a built-in method in VB.net? I have tried changing the line
Dim _buf As Byte() = CByte(parse(_cmd.ExecuteScalar()))
to
Dim _buf As Byte = CByte(_cmd.ExecuteScalar())
but it didn't work. I got the error "Value of type 'Byte' cannot be converted to '1-dimensional array of Byte'" on the line Response.BinaryWrite(_buf) , when I did that. At this point I really don't know what else to do, please help me solve the problem. Thank you in advance for your help.
-- modified at 12:36 Thursday 19th July, 2007
|
|
|
|
|
I am not sure but it could be that cbyte is returning a single byte rather than a byte array
Try
Dim _buf as byte() = ctype(cmd.ExecuteScalar(), byte())
|
|
|
|
|
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
|
|
|
|