Adding a user to a default role - asp.net

I want every person that registers in my website to be added to a default role "Users", question is how do I do it? :D
This is my register.aspx code:
<%# Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="register.aspx.cs" Inherits="register" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<form id="register1" runat="server"><center><b><asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
ContinueDestinationPageUrl="~/default.aspx" AnswerLabelText="תשובה סודית:"
CompleteSuccessText="המשתמש נוצר בהצלחה!"
ConfirmPasswordCompareErrorMessage="הסיסמאות חייבות להיות שוות."
ConfirmPasswordLabelText="וודא סיסמא:" CreateUserButtonText="הירשם"
EmailLabelText="כתובת דואר אלקטרוני:" PasswordLabelText="סיסמא:"
QuestionLabelText="שאלה סודית:" UserNameLabelText="שם משתמש:">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server" Title="הרשמה">
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreateUserWizard></b></center></form>
</asp:Content>
Thanks to anyone who helps!! :)

Nevermind, I used Roles.AddUserToRole(), thanks anyway!

Related

is it possible to see one user control on other user control?

I got one problem, I have three user controls say Control1,control2, control3.
I want to make Control1 into 3 divs and see contol1 UI in first part
control2-2nd part of div
Control3- in 3 Part of div
Is it possible?
I wanted to do this just for the sake i can maintain with less code .Is there any alternative .other this which will suit me best.
Please suggest
Yes, you can put multiple user control on a single user control. However your question is down voted the solution of your problem is as given below :
Create a sample website. Add Webusercontrol1.ascx ,Webusercontrol2.ascx, Webusercontrol3.ascx, Webusercontrol4.ascx in it and modify the code as given below.
Default.aspx page html
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="SO_1._Default" %>
<%# Register src="WebUserControl1.ascx" tagname="WebUserControl1" tagprefix="uc1" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<uc1:WebUserControl1 ID="WebUserControl11" runat="server" />
</asp:Content>
UserControl-1 Html : This is container user control and this will have all required user control on it.
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl1.ascx.cs"
Inherits="SO_1.WebUserControl1" %>
<%# Register Src="WebUserControl1.ascx" TagName="WebUserControl2" TagPrefix="uc1" %>
<%# Register Src="WebUserControl2.ascx" TagName="WebUserControl2" TagPrefix="uc2" %>
<%# Register Src="WebUserControl3.ascx" TagName="WebUserControl3" TagPrefix="uc3" %>
<%# Register Src="WebUserControl4.ascx" TagName="WebUserControl4" TagPrefix="uc4" %>
<p>
<b>DIV-1 Container User control</b></p>
<div>
<b>DIV1</b>
<br />
<uc2:WebUserControl2 ID="WebUserControl21" runat="server" />
</div>
<div>
<b>DIV2</b>
<br />
<uc3:WebUserControl3 ID="WebUserControl31" runat="server" />
</div>
<div>
<b>DIV3</b>
<br />
<uc4:WebUserControl4 ID="WebUserControl41" runat="server" />
</div>
UserControl-2 html
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl2.ascx.cs" Inherits="SO_1.WebUserControl2" %>
User Control-1
UserControl-3 html
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl2.ascx.cs" Inherits="SO_1.WebUserControl2" %>
User Control-2
UserControl-4 html
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl2.ascx.cs" Inherits="SO_1.WebUserControl2" %>
User Control-3

Getting "A page can have only one server-side Form tag" error, not using a master page

So I'm the new guy on the dev team, trying to update a "Dashboard" type page, which is the default landing page for our users. The default.aspx page consists of 16 Web User Controls (.ascx). I've been asked to add stock "widget" on the dashboard, so users can monitor our company's stock symbol. To allow for different timeframes (1 day, 5 day, 3 month, etc) I was planning on using a Menu (tabs) within a new .ascx. When I try to use a menu, I get the error "Control 'StockDisplay_StockMenu' of type 'Menu' must be placed inside a form tag with runat=server". If I wrap the menu in form tags, I get the "A page can have only one server-side Form tag" error.
Most search results suggest looking at the Master Page, but we're not using one here. I checked The default.aspx page, and it does not have any form tags. Other searches suggested removing < head> and < body> tags in the .ascx, which I've done, but still I have the issue.
Here's my stripped down code, which still produces the error:
<%# Control Language="VB" AutoEventWireup="false" CodeFile="UC_StockDisplay.ascx.vb" Inherits="UC_StockDisplay" %>
<%# Import Namespace="System.Data" %>
<form id="Form1" runat="server">
<asp:Menu ID="StockMenu" runat="server">
<Items>
<asp:MenuItem Text="One Day" />
<asp:MenuItem Text="Five Days" />
<asp:MenuItem Text="Three Months" />
<asp:MenuItem Text="Six Months" />
<asp:MenuItem Text="One Year" />
</Items>
</asp:Menu>
</form>
Here's the default.aspx:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%# Register src="UC_HelpUs.ascx" tagname="HelpUs" tagprefix="uc1" %>
<%# Register src="UC_ImportantNumbers.ascx" tagname="ImportantNumbers" tagprefix="uc2" %>
<%# Register src="UC_ImportantLinks.ascx" tagname="ImportantLinks" tagprefix="uc3" %>
<%# Register src="UC_Printers.ascx" tagname="Printers" tagprefix="uc4" %>
<%# Register src="UC_WorkOrder.ascx" tagname="WorkOrder" tagprefix="uc5" %>
<%# Register src="UC_RequestForms.ascx" tagname="UCRequestForms" tagprefix="uc6" %>
<%# Register src="UC_MiscLinks.ascx" tagname="MiscLinks" tagprefix="uc7" %>
<%# Register src="UC_Emergency.ascx" tagname="Emergency" tagprefix="uc8" %>
<%# Register src="UC_Floorplan.ascx" tagname="Floorplan" tagprefix="uc9" %>
<%# Register src="UC_Directory.ascx" tagname="Directory" tagprefix="uc10" %>
<%# Register src="UC_Weather.ascx" tagname="Weather" tagprefix="uc11" %>
<%# Register src="UC_Holiday.ascx" tagname="Holiday" tagprefix="uc12" %>
<%# Register src="UC_CoreValues.ascx" tagname="CoreValues" tagprefix="uc14" %>
<%# Register src="UC_MyInfo.ascx" tagname="MyInfo" tagprefix="uc15" %>
<%# Register src="UC_Travel.ascx" tagname="Travel" tagprefix="uc16" %>
<%# Register src="UC_StockDisplay.ascx" tagname="StockDisplay" tagprefix="uc17" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>IT Helpdesk</title>
</head>
<body style="background-color:#1B5B9D;">
<center>
<img src="images\banner2.gif" border=0><br>
<font face="Courier New Bold" size=5 color=white>Helpdesk 3.5</font><br>
<table width=100% cellspacing=10>
<tr>
<td width="33%" valign=top>
<uc1:HelpUs ID="HelpUs" runat="server" />
<br>
<uc3:ImportantLinks ID="ImportantLinks" runat="server" />
<br>
<uc10:Directory ID="Directory" runat="server" />
<br>
<uc6:UCRequestForms ID="UCRequestForms" runat="server"/>
<br>
<uc7:MiscLinks ID="MiscLinks" runat="server" />
</td>
<td width="33%" valign=top align=center>
<uc5:WorkOrder ID="WorkOrder" runat="server" />
<br>
<uc8:Emergency ID="Emergency" runat="server" />
<br>
<uc2:ImportantNumbers ID="ImportantNumbers" runat="server" />
<br>
<uc11:Weather ID="Weather" runat="server" />
<td width="33%" valign=top>
<uc17:StockDisplay ID="StockDisplay" runat="server" />
<br />
<uc9:Floorplan ID="Floorplan" runat="server" />
<br>
<uc4:Printers ID="Printers" runat="server" />
<br>
<uc15:MyInfo ID="MyInfo" runat="server" />
<br>
<uc14:CoreValues ID="CoreValues" runat="server" />
<br>
<uc12:Holiday ID="Holiday" runat="server" />
<br />
<uc16:Travel ID="Travel" runat="server"></uc16:Travel>
</td>
</tr>
</table>
</center>
</body>
</html>
After adding one control you have a form with runat="server" tag:
<form id="Form1" runat="server">
<asp:Menu ID="StockMenu" runat="server">
You already mentioned you have 16 usercontrol in one page. So you have 16 forms with runat="server" tag. Which is not allowed.
Solution: As Chris Lively suggested, strip out the the form tag from your wsercontrols. Add just one form tag in the page. You should be ok.
Here's how should all your controls should look like:
<asp:Menu ID="Menu1" runat="server">
<Items>
<asp:MenuItem Text="One Day" />
<asp:MenuItem Text="Five Days" />
<asp:MenuItem Text="Three Months" />
<asp:MenuItem Text="Six Months" />
<asp:MenuItem Text="One Year" />
</Items>
</asp:Menu>
And your page should look like:
<%# Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%# Register src="UC_HelpUs.ascx" tagname="HelpUs" tagprefix="uc1" %>
<%# Register src="UC_ImportantNumbers.ascx" tagname="ImportantNumbers" tagprefix="uc2" %>
<%# Register src="UC_ImportantLinks.ascx" tagname="ImportantLinks" tagprefix="uc3" %>
<%# Register src="UC_Printers.ascx" tagname="Printers" tagprefix="uc4" %>
<%# Register src="UC_WorkOrder.ascx" tagname="WorkOrder" tagprefix="uc5" %>
<%# Register src="UC_RequestForms.ascx" tagname="UCRequestForms" tagprefix="uc6" %>
<%# Register src="UC_MiscLinks.ascx" tagname="MiscLinks" tagprefix="uc7" %>
<%# Register src="UC_Emergency.ascx" tagname="Emergency" tagprefix="uc8" %>
<%# Register src="UC_Floorplan.ascx" tagname="Floorplan" tagprefix="uc9" %>
<%# Register src="UC_Directory.ascx" tagname="Directory" tagprefix="uc10" %>
<%# Register src="UC_Weather.ascx" tagname="Weather" tagprefix="uc11" %>
<%# Register src="UC_Holiday.ascx" tagname="Holiday" tagprefix="uc12" %>
<%# Register src="UC_CoreValues.ascx" tagname="CoreValues" tagprefix="uc14" %>
<%# Register src="UC_MyInfo.ascx" tagname="MyInfo" tagprefix="uc15" %>
<%# Register src="UC_Travel.ascx" tagname="Travel" tagprefix="uc16" %>
<%# Register src="UC_StockDisplay.ascx" tagname="StockDisplay" tagprefix="uc17" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>IT Helpdesk</title>
</head>
<body style="background-color:#1B5B9D;">
<form id="form1" runat="server">
<%-- your usercontrols and other tags --%>
</form>
EDIT: As you mentioned other usercontrols don't have forms, just adding form tag in the main page and remove that tag from usercontrol should solve your problem.

Problem with using ajax in visual studio

<cc1:Rating ID="Rating1" runat="server"
MaxRating="5"
CurrentRating="2"
CssClass="ratingStar"
StarCssClass="ratingItem"
WaitingStarCssClass="Saved"
FilledStarCssClass="Filled"
EmptyStarCssClass="Empty"
>
</cc1:Rating>
</asp:Content>
That rating control doesnt appear on the page!!
<%# Page Title="" Language="C#" MasterPageFile="~/YourGuruMaster.master" AutoEventWireup="true" CodeFile="PickTheBestAnswer.aspx.cs" Inherits="PickTheBestAnswer" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
<cc1:Rating ID="Rating1" runat="server"
MaxRating="5"
CurrentRating="2"
CssClass="ratingStar"
StarCssClass="ratingItem"
WaitingStarCssClass="Saved"
FilledStarCssClass="Filled"
EmptyStarCssClass="Empty"
>
</cc1:Rating>
<asp:TextBox ID="TextBox1" runat="server" Height="71px" Width="231px"></asp:TextBox>
</asp:Content>
The namespace should be AjaxControlToolkit and not AjaxControlToolkit.HTMLEditor
If you are using Ajax Control Toolkit .NET 3.5 with Visual studio 2008, you must have installed Visual Studio Service Pack 1 . I think it is your issue. Follow instructions which are given bellow, refer the "Note" part in that.
http://ajaxcontroltoolkit.codeplex.com/releases/view/90063

jQuery errorContainer practice

I'm trying to be able to place the error message when using jQuery validation to a asp.net label if the textbox is empty.
please advice how to modify my code to get that!!
here is my code:
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="js/jquery-1.4.1.js" type="text/javascript"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$("#aspnetForm").validate({
errorContainer: "#<%=TextBox1 %>",
errorLabelContainer: "#<%=TextBox1 %> #<%=Label1 %>",
wrapper: "li", debug: true,
submitHandler: function() { alert("Submitted!") }
})
});
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<p style="height: 313px">
<asp:TextBox ID="TextBox1" runat="server" class="required"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="Label" ></asp:Label>
</p>
</asp:Content>
I think
"#<%=TextBox1 %>"
means write the value of the default property of the textbox, which is the .Text property.
You should use
"#<%=TextBox1.ID %>"
and
"#<%=TextBox1.ID %> #<%=Label1.ID %>"
No to disqualify what you are doing now but I can't wrap my head around why you add a new plugin like JQ validation when you have a simple case of a required field validator which is a built in .net control

How can I enable live preview for FCKeditor in an ASP.Net site?

Over in this question, Scott writes that it is possible to get the current HTML for what's written in the FCKeditor by using FCKeditorAPI.__Instances['instanceNameHere'].GetHTML();
Could someone provide step-by-step instructions on how to accomplish this in an ASP.NET page? All I currently have so far in the .aspx file is this:
<%# Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<%# Page Title="" Language="C#" ... %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>Create a new piece</h2>
<form id="form1" runat="server">
<FCKeditorV2:FCKeditor ID="FCKeditor1" runat="server">
</FCKeditorV2:FCKeditor>
<input id="Submit1" type="submit" value="Submit" runat="server" />
</form>
</asp:Content>
In javascript
Well you can do this here:
<script type="text/javascript">
var oEditor = FCKeditorAPI.GetInstance(’IDFromFCKEditor’);
oEditor.Events.AttachEvent( 'OnSelectionChange', function() {
document.getElementById("PreviewDiv").innerHTML = oEditor.GetHTML(true);
}) ;
</script>
Source http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/JavaScript_API

Resources