ASP.NET Membership - Add extra field to ASP.Net Login page - asp.net-membership

Currently in My application, validating the users using the ASP.Net membership provider and the ASP.Net default Login page contains only Username and Password. This is working fine with this two fields. But as per my current requirement, need an extra field "Company" display as dropdownlist in ASP.Net Login page and validate the three Company, Username and Password using the ASP.NET membership provider. Is this possible or not, customize the ASP.Net Login page with an extra field using ASP.Net membership provider? Could you please give me some ideas how could I approach?

Membership provider's ValidateUser method only accept two parameters - username and password. Even if you override it, you cannot pass three parameters.
ValidateUser(string username, string password)
Basically, you cannot use Login control to validate for user. Instead, you want to validate user by yourself. Here is an sample code -
Note: I strip out codes in Login control for demo purpose.
<asp:Login ID="LoginUser" runat="server" OnAuthenticate="LoginUser_Authenticate">
<LayoutTemplate>
<asp:TextBox ID="UserName" runat="server" />
<asp:TextBox ID="Password" runat="server" TextMode="Password" />
<asp:DropDownList ID="CompanyDropDownList" runat="server">
<asp:ListItem Text="One" Value="1" />
<asp:ListItem Text="Two" Value="2" />
</asp:DropDownList>
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Log In" ValidationGroup="LoginUserValidationGroup" />
</LayoutTemplate>
</asp:Login>
protected void LoginUser_Authenticate(object sender, AuthenticateEventArgs e)
{
var companyName = LoginUser.FindControl("CompanyDropDownList")
as DropDownList;
if(MyValidateUser(LoginUser.UserName, LoginUser.Password,
companyName.SelectedValue))
{
FormsAuthentication.SetAuthCookie(LoginUser.UserName, false);
// Do something
}
}
Please make sure you use new ASP.NET Universal Providers

you can use the Profile Provider for this.
Alternatively, you could create your own table(s) that store additional user-related information. This is a little more work since you're on the hook for creating your own tables and creating the code to get and save data to and from these tables, but I find that using custom tables in this way allows for greater flexibility and more maintainability than the Profile Provider (specifically, the default Profile Provider, SqlProfileProvider, which stores profile data in an inefficient, denormalized manner).
Take a look at this tutorial, where you can find a walk through this process: Storing Additional User Information.

Related

Oracle Apex to receive form submit POST data

I am new to Oracle Apex.I am trying to receive POST data in Oracle Apex page. I want to submit a HTML form and receive that post submission in my Oracle Apex app. searched web but couldn't get suggestions.
In my Oracle database 11g, I have configured Apex 18.1 which is running in 8085 port and created some basic pages.
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="http://localhost:8085/apex/f?p=106:4:9735956410807:::::" method="post">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to Oracle Apex page.".</p>
</body>
</html>
This POST submission will be from external source and Apex app should process this submission.
Thanks in advance.
There are a couple options here:
You could create a webservice using APEX Restful services and sending there. It's probably much safer than exposing you application like you are doing. Worst case scenario you'll have to convert you form post to a json on the backend of the original app, which should be easy pease.
Why not just create a public page with an APEX form and execute a process after the submit happens? You have a tool that generate forms and you are building one from scratch?
*** Having said that, you might want to have the page in a different domain, site, etc... I still think you would be better telling on the other site that the person would be redirected and then sending it to the APEX form

Google Custom Search and a multi tenant multi domain web application

I'm developing an application that runs on several domains.
I want to use Google Custom Search on all of them. But GCS requires to provide the domain(s) of websites to search.
Is there any way to specify domains dynamically? In theory I can have thousands of domains, and I don't like the idea of adding all of them manually.
Google provide a service where you can Create a Custom Search Engine on the fly.
To use this you have to have real links on your page and not JavaScript generated links – this is so the remote service can parse your page.
<form name="cse" id="searchbox_demo" action="http://www.google.com/cse">
<input type="hidden" name="cref" value="" />
<input type="hidden" name="ie" value="utf-8" />
<input type="hidden" name="hl" value="" />
<input name="q" type="text" size="40" />
<input type="submit" name="sa" value="Search" />
</form>
<script type="text/javascript" src="http://www.google.co.uk/cse/tools/onthefly?form=searchbox_demo&lang="></script>
stackoverflow<br />
serverfault<br />
superuser
Therefore you would need to use some mechanism to dynamically create your site list page (e.g. Ruby, Python, PHP, ASP, JSP etc). From my limited experimentation it appears that the on the fly service aggressively cache your requests for the creation of a custom search engine based on the requesting page (I'm not sure how long the cache lasts). It would therefore appear that you will not be able to add and drop search sites from your list very quickly. As a workaround you could change the url that requested the custom search box for every change.

ASP.Net MVC 3 Razor Create Report

I have ASP.Net MVC3 project with Razor template, and I need to make a reporting tool for summary reports and detailed reports.
I do not know how to create such reports in MVC3. Could anyone give me an example for creating these reports?
There isn't a built-in control for reports, there is however an HTML helper for displaying charts. Please see example here
SSRS reports are not supported by default in MVC 3, therefore you need to use a report viewer control. Article explaning how to do this can be found here
first, i must configure the dataset in my project. because i use storedprocedure, so i must add new table adapter in my dataset.
then i add new item (for the report file) in my project and design the report using report wizard.
after that, for showing the report in my project, i add new web form and in my web form, drag the report viewer and script manager. choose the design view to set up the report.
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<rsweb:ReportViewer ID="ReportViewer1" runat="server" Font-Names="Verdana" SizeToReportContent="true"
Font-Size="8pt" InteractiveDeviceInfos="(Collection)"
WaitMessageFont-Names="Verdana" WaitMessageFont-Size="14pt">
<LocalReport ReportPath="Reports\rptbooking.rdlc">
<DataSources>
<rsweb:ReportDataSource DataSourceId="ObjectDataSource1" Name="DataSet1" />
</DataSources>
</LocalReport>
</rsweb:ReportViewer>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{0}" SelectMethod="GetData"
TypeName="rptBatchClose.RDYGetawayDataSetTableAdapters.DataTable1TableAdapter">
</asp:ObjectDataSource>
</div>
</form>
</body>
this is the simple way to make SSRS report in my MVC3 Project.

ASP.MVC3 is client side validation enabled by default?

In my Layout page, i have the following links to the validation Javascript files,
<script src="#Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"> </script>
<script src="#Url.Content("~/Scripts/jquery.validate.min.js")"type="text/javascript"> </script>
<script src="#Url.Content("~/Scripts/jquery.validate.unobtrusive.js")"type="text/javascript"></script>
My entities are decorated with validation attributes like
[Required(ErrorMessage ="Please enter a customer name")]
public string CustomerName { get; set; }
Then in my view i have validation messages specified after the update fields like so
<div class="label-for">#Html.LabelFor(model => model.CustomerName)</div>
<div class="editor">#Html.EditorFor(model => model.CustomerName)</div>
#Html.ValidationMessageFor(model => model.CustomerName)
The validation is working however its not on the client side, the way i understand this is that error messages should be displayed when one of the fields is left blank afer tabbing to another field, is there anything else required to get client side validation working?
IIRC there were some incompatibilities between jquery and jquery.validate versions. You seem to be using an old version of jquery 1.4.4. Try updating with the latest. For example install the ASP.NET MVC 3 Tools Update and create a new ASP.NET MVC project in Visual Studio which will get you the proper versions of the following scripts: jquery, jquery.validate and jquery.validate.unobtrusive.
May be this work: Make sure that in your web.config file, you set "ClientValidationEnabled" to "True"
<appSettings>
<add key="ClientValidationEnabled" value="true"/>
</appSettings>
NOTE: In MVC3 web project, there were two web.config files one under "View" folder another under root web project. make sure that the one in the root does not override the other.
jQuery validation has nothing to do with your validation mechanism. Maybe Microsoft.Ajax.Validation should be the responsible. But to use jquery.validation, you should write code. That's all. It doesn't do anything out of the box.

Cannot Add User Control to AJAX Toolkit TabContainer

I have a user control called "Request" that I am able to display outside of a TabContainer on my SharePoint 2010 application page. So the following works:
<UserControl:Request ID="Request1" runat="server" />
<Ajax:TabContainer ID="TabContainer1" runat="server" ScrollBars="None" Enabled="true">
<Ajax:TabPanel ID="TabPanel1" runat="server" HeaderText="Request">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label">Mylabel</asp:Label>
</ContentTemplate>
</Ajax:TabPanel>
</Ajax:TabContainer>
However, if I merely move the UserControl line into the ContentTemplate section, replacing the existing Label control, the page bombs out with a runtime error and "Request failed".
The workaround for me was to COPY, not MOVE, the user control into the ContentTemplate section, then give the copy a different ID and set the original (which I don't need) to visible="false". I have no idea why this works and it looks like a bug to me. If anyone can explain it, please do so...

Resources