Reputation: 1
I am creating a navigation menu and one option from the menu calls a changepassword.aspx. I want to pass a variable (userid) for this pane so that when changing the password, it will update the correct user. Below is my code from my home.aspx. When I hover over the Change password link, my link does not include the value in the cuuser variable.
<ul id="Adminmenu">
<li><a href="#">Hyperlink 1</a><span class="darrow">▼</span>
<ul class="sub1">
<li><a href="#">hyperlink 1.1</a></li>
<li><a href="#">hyperlink 1.2</a></li>
<li><a href="#">hyperlink 1.3</a></li>
<li><a href="#">hyperlink 1.4</a></li>
</ul>
</li>
<li><a href="#">hyperlink 2</a><span class="darrow">▼</span>
<ul class="sub1">
<li><a href="#">hyperlink 2.1</a></li>
<li><a href="#">hyperlink 2.2</a></li>
<li><a href="#">hyperlink 2.3</a></li>
<li><a href="#">hyperlink 2.4</a></li>
</ul>
</li>
<li><a href="#">hyperlink 3</a><span class="darrow">▼</span>
<ul class="sub1">
<li><a href="#">hyperlink 3.1</a></li>
<li><a href="#">hyperlink 3.2</a></li>
<li><a href="#">hyperlink 3.3</a></li>
<li><a href="#">hyperlink 3.4</a></li>
</ul>
</li>
<li><a href="#">hyperlink 4</a><span class="darrow">▼</span>
<ul class="sub1">
<li><a href="#">hyperlink 4.1</a></li>
<li><a href="#">hyperlink 4.2</a></li>
<li><a href="#">hyperlink 4.3</a><span class="darrow">▶</span>
<ul class="sub2">
<li><a href="#">hyperlink 4.3.1</a></li>
<li><a href="#">hyperlink 4.3.2</a></li>
<li><a href="#">hyperlink 4.3.3</a></li>
<li><a href="#">hyperlink 4.3.4</a></li>
</ul>
</li>
<li><a href="#">hyperlink 4.4</a></li>
</ul>
</li>
<li><a href="pswrdchange.aspx?userid=" + cuuser>Change Password</a></li>
<li><a href="#">hyperlink 6</a></li>
</ul>
My vb.code has a preinit module when loading the page which has the following:
Private Sub home_PreInit(sender As Object, e As EventArgs) Handles Me.PreInit
cuuser = Request.QueryString.Get("userid")
End Sub
Thank you in advance for your help
Upvotes: 0
Views: 1486
Reputation: 9480
This is very wrong approach for several reasons.
1. On pswrdchange.aspx
page anyone can change username=John
to username=Peter
.
2. On your home page query string username=
most probably doesn't exist.
3. If you want to use your approach change your code like this.
<%--HTML--%>
<a runat="server" id="pswrdchange" href="pswrdchange.aspx?userid=<%#cuuser%>">
'VB
Protected ReadOnly Property cuuser() as String
Get
Return Request.QueryString("cuuser")
End Get
End Property
Upvotes: 1