Commentbox instead of text box? - asp.net

I want the user to be able to leave comments, a few sentences perhaps. TextBox is to no use, but I see no asp:CommentBox
Any advice on what to use instead?
Thanks

Set property TextMode to MultiLine
As this
<asp:TextBox ID="Text1" runat="server" TextMode="MultiLine" />
You can see more on MSDN http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.textbox.textmode.aspx

If the comments part of your project is so important i suggest using third-parties for these such functions
check these 2 sites
Disqus Elevating the discussion, anywhere on the web.
livefyre WE MAKE YOUR SITE SOCIAL.
i know that's not answer to your question, but i think you should at least know they are exist.

Related

"!" while defining text for asp.net control - for example a checkbox text

I have come across the following code while troubleshooting an issue. I am not sure why someone would prefix "!" mark to the text "Forgot your password?" for the control. I am not an experience asp.net dev.
<asp:LinkButton id="btnPassReminder" runat="server" CssClass="SmallLink"
CausesValidation="false" OnClick="btnPassReminder_Click">!Forgot your password?
</asp:LinkButton>
There is no specific reason from an ASP.NET perspective (e.g. it is not an accessKey), it could be used by the font as an icon or replaced elsewhere, but there is not enough code to confirm this.

Sharepoint FormField default value?

Is it possible to add default values to a sharepoint FormField object?
Here is my code:
<SharePoint:formfield runat="server" id="ff8{$Pos}" ControlMode="Edit" FieldName="Body" ItemId="{#ID}" __designer:bind="{ddwrt:DataBind('u',concat('ff8',$Pos),'Value','ValueChanged','ID',ddwrt:EscapeDelims(string(#ID)),'#Body')}" />
<SharePoint:fielddescription runat="server" id="ff8description{$Pos}" FieldName="Body" ControlMode="Edit" />
Basically, I want the form field's default value to be more than just the Body parameter (perhaps 2 parameters and some custom text). Is this possible?
(Also, I know you can substitute the SP form Field with an ASP TextBox, but I'm running into problems with that--specifically, the text box doesn't support rich text, and the post-back doesn't preserve line breaks.)
Thanks in advance!
It looks like I was able to solve this. Other forums had me using an ASP Text box and writing code behind in C#, but it's really not necessary if you use a Sharepoint:InputFormTextBox instead.
<SharePoint:InputFormTextBox ID="ff8{$Pos}" RichText="true" text="{concat(#Body, "CustomText", #secondparameter)}" RichTextMode="FullHtml" TextMode="MultiLine" runat="server" __designer:bind="{ddwrt:DataBind('u',concat('ff8',$Pos),'Text','TextChanged','ID',ddwrt:EscapeDelims(string(#ID)),'#Body')}" Width="99%" Rows="10"/>
If this was an obvious solution, please forgive my ignorance. This is new territory for me.

client id mode on 2 identical id's

I have an control1.ascx page
and control2.ascx page
both of them have this element:
<asp:TextBox runat="server" ID="txt_name" ClientIDMode="Static"></asp:TextBox>
page.aspx contains both of the controls.
so now the page contains input type text with the id "txt_name" X2.
I am wondering how it is working? can someone explain?
Ideally, you want to use ClientIDMode="Static" only if you are sure that no other control has same name in the page.
For example, you really want to access the ServerControl from external javascript file (althought it is not a good design).
If you are not sure, you want to use Predictable.
As your are using ClientIDMode="Static" thus control's id will be rendered exactly as it is.
ID will be rendered directly. See MSDN docs, this Blog is a good read.
ASP.Net 4+ supports various modes to generate ClientIDs for controls.
Here is a reference for MSDN on ClientID and its' generation modes: http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientid(v=vs.100).aspx
To see how ClientID generation works, you may want to refer to this link :
http://www.codeproject.com/Articles/108887/Client-Ids-Generation-with-ASP-NET-4-0
(It has visual explanations on how the ClientID generation works in different cases)
Hope this helps.

Comments Within an Asp Tag [duplicate]

This question already has answers here:
Can I place a comment inside a tag in ASP.NET?
(3 answers)
Closed 8 years ago.
I know how to comment any code in the ASP page, but I want to ask is this is allowed in ASP to comment the line within any ASP tag. For example:
<asp:RequiredFieldValidator runat="server" ID="rfv01" ControlToValidate="txtName"
Enabled="False" Display="None" ErrorMessage="Error"
<%--Some Comments--%>
ValidationGroup="TestGroup" />
I know its very basic question, but couldn't find the answer at the moment. Can anybody help me out?
No, it isn't.
You might be able to achieve a similar effect by using a fake attribute/property, but I don't know how well the ASP.NET parser would handle that:
<asp:RequiredFieldValidator runat="server" ID="rfv01" ControlToValidate="txtName"
Enabled="False" Display="None" ErrorMessage="Error"
comments="--Some Comments--"
ValidationGroup="TestGroup" />
No, you cannot. You can't embed <% %> inline constructs in server tags. You can't embed them in non-server tags either. In the first case you'll get a compile-time error, in the latter case a 'runtime-error' inasmuch as it will produce bad markup, so <div <%-- some comment --%>></div> will result in that element not being rendered in Chrome where other browsers might handle it differently.
P.S. My original answer addressed the wrong question, due to my own fault.

How to validate ID number in asp.net?

I am new at this so be easy on me... :)
I need to validate if a the ID number that the user typed in my site is a valid ID.
How do I check it?
Do I need to use RegularExpressionValidator?
More over, I also need to validate the credit card number, I found a few RegularExpressions for that in the net but each one is different from the other and I am not sure which one to use..
Does anyone know od a working expression that will suit all credit cards??
Thanks,
Tsil.
You never need to use the RegexValidator, it's just handy sometimes.
EDIT: a Regex can only check for a string-pattern and can't do any calculations or other checks that require numbers as opposed to "sequences of digits".
It all depends on what you consider a valid "ID". Is any number "valid" or are there more rules?
For a creditcard number you also need to specify what you consider valid: just a number of digits (12 I think?) with maybe added dots or spaces? Or do you want to know whether that card itself is valid? That's a different problem entirely!
EDIT: for a SSN, see wikipedia.
What kind of ID are you talking about? A social security number or a User ID to login?
Since you are talking about it in the context of a Credit card and Regular Expression validators, I will assume that you are talking about a Social Security number.
Anyways, if you Are talking about Login controls or such please go here.
Regarding Social Security number, this depends on what country the person is from and how the individual country sets up their numbers, but to give you a little taste of what you might want to do, check out How to use Regulat Expression Validators.
However, Please, please, please do not validate the credit card number yourself. There are Bank Services that you can use for this, head over to PayPal and check their API for C#, this will most certainly make your users feel more comfortable on your site.
Also use SSL.
Regular expression validator example
<%# language="C#" %>
<form id="form1" runat="server">
<asp:TextBox ID="txtName" runat="server"/>
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
<asp:RegularExpressionValidator ID="regexpName" runat="server"
ErrorMessage="This expression does not validate."
ControlToValidate="txtName"
ValidationExpression="^[a-zA-Z'.\s]{1,40}$" />
</form>
If you want to try out some regular expressions head over to the greatest resource there is. And don't forget to read this.
You might also want to read User Input validation in ASP.NET from msdn and Learn ASP.NET from Microsoft has some great videos on ASP.NET Security that you might find usefull.

Resources