ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Redirect user to different page based on logged in user in ASP.Net<p>Hi <a class="username" rel="micah"> micah</a>,</p> <p>I have created sample code which fullfill your requirement.</p> <p><span style="text-decoration: underline;">HTML</span></p> <pre class="brush: html">&lt;div&gt; UserName: &lt;asp:TextBox ID=&#34;txtUserName&#34; Placeholder=&#34;Enter a UserName&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;br /&gt; Password :&lt;asp:TextBox ID=&#34;txtPassword&#34; Placeholder=&#34;Enter a Password&#34; TextMode=&#34;Password&#34; runat=&#34;server&#34; /&gt; &lt;br /&gt; &lt;br /&gt; &lt;asp:Button ID=&#34;btnSubmit&#34; Text=&#34;Submit&#34; OnClick=&#34;Validate&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt;</pre> <p><span style="text-decoration: underline;">C#</span></p> <pre class="brush: csharp">protected void Validate(Object sender, EventArgs e) { int companyId; string constr = ConfigurationManager.ConnectionStrings[&#34;Constring&#34;].ToString(); using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand(&#34;SELECT * FROM UserDetails WHERE UserName=@UserName AND Password=@Password&#34;, con)) { DataTable dt = new DataTable(); SqlDataAdapter sda = new SqlDataAdapter(cmd); cmd.Parameters.AddWithValue(&#34;@UserName&#34;, txtUserName.Text); cmd.Parameters.AddWithValue(&#34;@Password&#34;, txtPassword.Text); sda.Fill(dt); if (dt.Rows.Count &gt; 0) { companyId = int.Parse(dt.Rows[0][&#34;CompanyId&#34;].ToString()); switch (companyId) { case 1: Response.Redirect(&#34;A.aspx&#34;); break; case 2: Response.Redirect(&#34;B.aspx&#34;); break; case 3: Response.Redirect(&#34;C.aspx&#34;); break; } } } } }</pre> <p><span style="text-decoration: underline;">SQL</span></p> <pre class="brush: sql">CREATE TABLE UserDetails ( UserId INT ,UserName VARCHAR(20) ,Password VARCHAR(20) ,CompanyId INT ); ------------------------------ CREATE TABLE CompanyName ( CompanyId INT ,CompanyName VARCHAR(20) ); </pre> <p><span style="text-decoration: underline;">Screenshot</span></p> <p><img src="http://i988.photobucket.com/albums/af3/mudassarkhan/595047_1.gif" alt="" width="472" height="220" /></p> <p>&nbsp;</p> <p>&nbsp;</p> <p>&nbsp;</p>http://www.aspforums.net/Threads/595047/Redirect-user-to-different-page-based-on-logged-in-user-in-ASPNet/http://www.aspforums.net/Threads/595047/Redirect-user-to-different-page-based-on-logged-in-user-in-ASPNet/Mon, 03 Oct 2016 08:03:54 GMT