Linking VB.Net Repeaters to Profile Pages - vb.net

SOCIAL NETWORK PROJECT.
This is the code placed inside the repeater:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("uname", "~/XsProfile.aspx?uname={0}") %>'>
<%# Eval("uname")%>
</asp:HyperLink>
The code will generate links for x number of times.
On clicking on the link,
It redirects to that person's profile.
Details need to be fetched on the person's profile.
What would go in the following code to achieve this output?
<asp:AccessDataSource ID="fav_music_data" runat="server"
DataFile="~/paperhome_data.accdb"
SelectCommand="SELECT * FROM [userinfo]
WHERE ([uname] = *****?*****)">
</asp:AccessDataSource>
What exactly goes into 'WHERE' clause?

Since your URL has ?uname= the answer should be in ASP.NET's Request object. You might be able to use Request("uname") but that's generally frowned upon.
A malicious user could enter their username as:
''; drop table userinfo;
...and very bad things could happen to your site.
I appreciate that you're trying to do your work simply (e.g. using declarative datasources) but at some point you're probably going to need to write some code.

Related

My HTML page does not upload at the top of the page

I am just in my first year of a computing degree. I am looking for a job, unfortunately I have to go back to accounts as nobody is keen to hire someone after just one year of computing studies, with almost zero experience. However, I thought to make it interesting and create an online Curriculum Vitae, as my job history is all over the place and it's a lot harder to keep in on a 2 page word doc.
What I have done so far, it's here: http://lavinia.gear.host/
Just a simple site, using Bootstrap (as I was curious to try it), minimal JS, HTML and CCS.
As you notice, when you go on the website, it does not show the top part, the actual site menu, how normally any site uploads or refreshes. It starts almost at the bottom of the page, where the contact form is. I did remove the contact form but it's the same thing, the webpage defaults to the same area. I really have no idea why and how can I solve it? Maybe it's something to do with Bootstrap, some hidden thing I am not aware of?
If you want the actual code, I will supply it but since it's quite a lot for a small page, I thought maybe you can just view the code source directly.
Any advice is much appreciated. I cannot send a E Resume when it's always getting to that contact form, it's annoying, even if accounts people will look at it.
Thank you,
Lavinia
That's because your input element is set to autofocus:
<input type="text" size="50" name="VisitorName" maxlength="30" required="" autofocus="">
Remove the autofocus attribute and it should be fine:
<input type="text" size="50" name="VisitorName" maxlength="30" required="">

_ServerClick event and Response.Redirect: wrong redirection

Perhaps this question is a bit too general, but I'll try to narrow it down by explaining my scenario.
I have a login page, with an html input button:
<input runat="server" id="btnLogin" type="submit" value="Login"></input>
The button triggers the btnLogin_ServerClick event which runs a validation routine.
If the user is validated the following happens:
HttpContext.Current.Response.Redirect("~/myPage.aspx")
This is all good in development environment.
However, after I deployed my application, the validated user would still be redirected to the localhost URL, instead of the application URL corresponding to the root directory.
After lots of trials and errors, I've fixed the issue by changing the button to a webcontrol namespace button:
<asp:Button runat="server" ID="btnLogin" Text="Login"/>
This triggers a Click event in the code behind.
The routine is exactly the same as in the development environment, but the user is now redirected to the appropriate URL.
So, could anyone explain why the ServerClick event was making Response.Redirect "behave" differently?

Using FileUpload in DNN Setting.ascx possible?

first time asking a question here.
I'm making a DNN module and in the Setting.ascx I'm trying to add any form of FileUpload in there. I'm successful at adding ASP's FileUpload as well as Telerik's RadUpload, but when I click a button I added to save and examine the uploaded the file it's empty and no longer holding any data. I thought I was coding it wrong at first, but after adding it into the View.ascx instead it works perfectly. Of course that's not where I want it to be.
I believe the problem might be how the Setting.ascx works in DNN. I believe it's using a form of AJAX to display it so that might be interfering. Hard to say though. While I'm at it can anyone confirm that Setting.ascx is using AJAX and that button clicks cause asynchronous postbacks? Thanks.
You're right with your thought that the form uses AJAX (formerly via UpdatePanel, now via RadAjaxPanel in DNN 6.x), and that's what's interfering with the upload. In most scenarios, you'd just switch to a regular postback by calling ScriptManager.RegisterPostBackControl, but in the settings case, you don't have a direct reference to the LinkButton that saves the settings.
You'll probably need to add your own button to the form to do the upload after the user has selected the file. DNN's own UrlControl uses a system like that, where there's an Upload button next to the Browse button. DNN also has a newer DnnFilePicker control, which might also encapsulate what you want. You'll just need to add an # Register directive to use those. For example:
<%# Reference tagPrefix="dnn" tagName="UrlControl" Src="~/controls/URLControl.ascx" %>
<%# Reference tagPrefix="dnn" Assembly="DotNetNuke.Web" Namespace="DotNetNuke.Web.UI.WebControls" %>
<dnn:UrlControl runat="server" ID="FileUpload"
ShowLog="false"
ShowNewWindow="false"
ShowTrack="false"
ShowImages="false"
ShowNone="false"
ShowTabs="false"
ShowUrls="false"
ShowUsers="false"
ShowFiles="false"
ShowUpLoad="true" />
<dnn:DnnFilePicker runat="server" ID="FilePicker"
FileFilter="jpg,png,gif" />
Man, just don't put a updatepanel outside your ascx control
If you need to use updatepanel, put it inside the ascx. That will resolve your problem!
I was able to solve this problem by doing the following:
Create my own submit button as opposed to relying on the "Save" button built into the page
Adding the following to my LoadSettings() method:
ScriptManager.GetCurrent(this.Page).RegisterPostBackControl(cmdUpload);
Where cmdUpload is the ID of my submit button.
You will need to add a reference to System.Web and System.Web.Extensions for this to compile.

Finding page id of parent form from pop up form

I have two pages
Master page
page using the master page
I am opening a pop up using "window.open" in the second page.
I have textbox control in the second page and trying the find the control in the pop up page using below code.
window.opener.document.getElementById('textbox').value
This code could not found out the control.
Then I checked the page source of second form and dound out the format of control id. It was like below.
"_ctl0_ContentPlaceHolder1_textbox"
and changed the code to below and got success.
"window.opener.document.getElementById('_ctl0_ContentPlaceHolder1_textbox').value"
My query is -> I am not about this approach. Please correct if i am doing anything wrong.
With ASP.NET 4.0 you have the option to set ClientIDMode that could help you in this case.
Setting ClientIDMode to "Static" will ensure that your ID value will not be altered by the framework.
In your page where you have textbox:
<asp:TextBox ID="MyTextBox" runat="server" ClientIDMode="Static" />
Then you should be able to get the value by doing something like this:
window.opener.document.getElementById('textbox').value
Ref: MSDN - ClientIDMode
The problem is that if you use a masterpage the controls of your contentpage will be renamed making it hard to access them from JavaScript.
Use the following code to solve the problem:
<asp:TextBox ID="textbox" runat="server" ClientIDMode="Static"></asp:TextBox>

Custom Code into the Standard DotNetNuke Login?

Where can I find the function that handles the login for DNN? I would like to add custom features to the login and I don't see the function in Login.ascx.vb (unless I missed it).
There is a tag and a tag that forms the login. I figure one of these has the actual "Login" button, but I cannot seem to figure out where they're coming from.
Here is as far as I've found where the login is located
<DNN:DNNTabStrip
ID="tsLogin"
runat="server"
TabRenderMode="All"
CssTabContainer="LoginTabGroup"
CssContentContainer="LoginContainerGroup"
DefaultContainerCssClass="LoginContainer"
DefaultLabel-CssClass="LoginTab"
DefaultLabel-CssClassHover="LoginTabHover"
DefaultLabel-CssClassSelected="LoginTabSelected"
visible="false" />
<asp:Panel ID="pnlLoginContainer" runat="server" style="text-align:left" CssClass="LoginPanel" Visible="false" />
Check out the /desktopmodules/AuthenticationServices directory. The out-of-the-box login control should be coming from DNN/Login.ascx.
You should be able to add user controls to that file.