_ServerClick event and Response.Redirect: wrong redirection - vb.net

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?

Related

Does launchUriAsync work with .edu sites?

I've created a JavaScript Windows Store blank app, and added the following code into it.
var url = new Windows.Foundation.Uri("http://www.google.com")
Windows.System.Launcher.launchUriAsync(url);
when debugging my program the above launches google without fail, but if I put a .edu site or something that ends in .aspx, the site won't launch.
I'm not able to reproduce this. Perhaps there's something in how you're doing this that's causing the issue.
To try to repro, here's what I did.
Started with the JavaScript Blank app template.
Added a button to default.html, on the line following the <p> element: <input id="Button1" type="button" value="Launch" />
Added an event handler for the button in default.js, just after the call to WinJS.UI.ProcessAll: document.getElementById("Button1").addEventListener("click", launchUri);
Added the launchUri function, as follows, to default.js:
launchUri:
function launchUri() {
var uri = new Windows.Foundation.Uri("http://www.communitymegaphone.com/Default.aspx");
Windows.System.Launcher.launchUriAsync(uri);
}
Works fine for me, both with aspx (as shown above) as well as for .edu addresses.
If you're still not able to make it work, please post some additional code for context.
Hope that helps.
For more info on Windows Store app development, register for Generation App.

joomla user authentication by my own custom written form inputs

I've been struggling to find out about user authentication using your own form elements.
In order to make it clear, heres what i want to do.
I'm going to have a button which is going to redirect to a page.
Now, this page can be redirected to in the following ways.
A popup opens where the user needs to enter their email address and password.
My form is like this
<form action="userlogin.php" method="post">
<ul>Email
<li><input type="text" id="email" name="email" /></li>
</ul>
<ul>Password
<li><input type="password" id="pass" name="pass" /> </li>
</ul>
</form>
The user clicks the submit button and if the email address and password exist then we have a successful login and if they dont then we add that user in the database and then redirect.
I dont understand how to authenticate user login using this form i've mentioned about. Which file do i have to post it to and how can it work like a normal joomla login.
Please do help.
Thanks.
You can write your own authentication routine relatively easily in two steps.
Authentication Logic
For the authentication logic, in the plugins folder, there is another folder called "authentication". Aside from the default joomla authentication, there is another called "example.php", which you can clone and work on from there. These are the plugins that you can enable/disable in the plugins manager in your Joomla Administrator, so you can look at them and see the different ways that they authenicate (gmail, openid, etc.).
Be sure to scan/replace all the naming used in the copied file (it's not very big), and when you're happy with it, make an entry in table jos_plugins so that you can enable it in the Joomla administrator.
Your Form (using template atomic as the example, and assuming you're using mod_login)
Within /templates/atomic/html/mod_login you should have, a file called default.php. This is where you change the form to suit your needs, and incorporate into the authentication logic your wrote in the plugin.
Popup Approach
That will depend on the template you're using, and how it, or you, generally handle popups. Rockettheme have many popup modules (some being free) which demonstrate how you could do it that way, or jquery if you're comfortable with that, the list goes on....
You could override the existing login form and open this in a modal popup?

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.