Getting data from HTML to C# - c#

I am using this HTML code (bootstrap) to allow users to enter tags
<div class="bootstrap-tagsinput"> <span class="tag label label-info">test tag<span data-role="remove"></span></span> <span class="tag label label-info">testing <span data-role="remove"></span></span> <span class="tag label label-info">issue <span data-role="remove"></span></span> <input size="1" type="text"> </div>
So the output
My question is, I cannot figure out how do I read this text in C# (asp.net Web forms) because it's not ASP:TextBox
Is this possible to read these tags in C#?
Thank you

So by looking at the documentation here: https://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/ you should be applying data-role="tagsinput" to the input element. This means you should be able to do something like:
Important Update : I threw this together before my morning coffee had kicked in. Note that asp:button has become asp:TextBox
<div class="bootstrap-tagsinput">
<span class="tag label label-info">test tag<span data-role="remove"></span></span>
<span class="tag label label-info">testing <span data-role="remove"></span></span>
<span class="tag label label-info">issue <span data-role="remove"></span></span>
<asp:TextBox ClientIDMode="Static" ID="tags" runat="server" data-role="tagsinput" />
</div>
You can then access the values from tags as a comma delimited string.
Alteratively you could try
<div class="bootstrap-tagsinput">
<span class="tag label label-info">test tag<span data-role="remove"></span></span>
<span class="tag label label-info">testing <span data-role="remove"></span></span>
<span class="tag label label-info">issue <span data-role="remove"></span></span>
<input id="tags" runat="server" size="1" type="text" data-role="tagsinput" />
</div>
This will make the text input available as a comma delimited string server side, again using tags.
Finally the least webformy option, just give the input a name attribute
<div class="bootstrap-tagsinput">
<span class="tag label label-info">test tag<span data-role="remove"></span></span>
<span class="tag label label-info">testing <span data-role="remove"></span></span>
<span class="tag label label-info">issue <span data-role="remove"></span></span>
<input name="tags" size="1" type="text" data-role="tagsinput" />
</div>
You can then access it serverside with Request.Form["tags"], with, you guessed it, the tags as a comma delimited string.

Try this approach, using JQuery:
Client side:
<div class="bootstrap-tagsinput">
<span class="tag label label-info">test tag<span data-role="remove"></span></span> <span class="tag label label-info">testing <span data-role="remove"></span></span> <span class="tag label label-info">issue <span data-role="remove"></span></span>
<input size="1" type="text">
</div>
<input type="submit" id="sendTagsToServer" text="Send Tags To Server!"/>
<!--Both buttons are invisible, to postback and send parameters-->
<asp:Button ClientIDMode="Static" ID="postbackButton" runat="server"
Style="display:none;" />
<asp:HiddenField ClientIDMode="Static" ID="tagsString" runat="server" />
<script>
$(document).ready(function(){
$("#sendTagsToServer").on("click",function(){
//get values from tags
var tags= $(".tag");
//save values in hidden
var tagText = "";
tags.each(function(index){
tagtext = tagText + "&" + $(this).text();
});
$("#tagsString").val(tagText);
//postback to server
$("#postbackButton").click();
});
});
</script>
Server side:
protected void btnPB_Click(object sender, EventArgs e)
{
//read tags, server side
string[] param = tagsString.Value.Split("&");
}
The trick here is use two inputs, both hidden, one to postback and one to send parametters and of course, you can use Javascript instead of JQuery.

Related

Find text from html with matches with regex pattern

I want a regex solution to find some text value which looks like MLA818214667 and this value placed in a id like id="MLA818214667". There should be 3 type of pattern to find these value from HTML.
It should start with MLA and placed in id="".
The number after MLA should be more than 6 characters long.
The number should be fully numeric not string mixed.
Note: I want to avoid HtmlAgilityPack for this case because the text not always valid html. So i want to treat it as text not html and need solution without any html parser
C#:
var listOfIds = new List<string>();
string html = #"below html sample goes here";
Match match = Regex.Match(input, #"/([A-Za-z0-9\-]+)\.$",
RegexOptions.IgnoreCase);
//from matched ids it should be added in list listOfIds
Html:
<span class="main-title">
Casco Integral Halcon H57 + Combo Termico Invierno Sti Motos
</span>
</h2>
<div class="item__status">
<div class="item__condition">541 vendidos</div>
</div>
</div>
</a>
<form class="item__bookmark-form" action="/search/bookmarks/MLA614364106/make" method="post" id="bookmarkForm" class="bookmark-form">
<button type="submit" class="bookmarks favorite" data-id="MLA614364106">
<div class="item__bookmark">
<div class="icon"></div>
</div>
</button>
<input type="hidden" name="method" value='add'/>
<input type="hidden" name="itemId" value='MLA614364106'/>
<input type="hidden" name="_csrf" value="5fe7b4e6-19d3-42bc-a3bb-15eaeee81f64"/>
</form>
</div>
</li>
<li class="results-item highlighted article grid item-info-height-179">
<div class="rowItem item highlighted item--grid item--has-row-logo new" id="MLA751765547">
<div class="item__image item__image--grid">
<div class="images-viewer" item-url="https://articulo.mercadolibre.com.ar/MLA-751765547-casco-moto-hawk-htl-dr46-rebatible-lett-store-_JM#position=5&type=item&tracking_id=897c653e-1565-4371-8a4d-b2ea29d09d4d" item-id="MLA751765547">
<div class="carousel">
<ul>
<li><a href="https://articulo.mercadolibre.com.ar/MLA-751765547-casco-moto-hawk-htl-dr46-rebatible-lett-store-_JM#position=5&type=item&tracking_id=897c653e-1565-4371-8a4d-b2ea29d09d4d" class="item-link item__js-link">
<img class='lazy-load' width='284' height='284' alt='Casco Moto Hawk Htl Dr46 Rebatible Lett Store' src='https://http2.mlstatic.com/casco-moto-hawk-htl-dr46-rebatible-lett-store-D_NQ_NP_624166-MLA31021954439_062019-W.jpg'/>
</a>
</li>
</ul>
</div>
</div>
</div>
<span class="item-loading__status-bar item-loading__hide"></span>
<a href="https://articulo.mercadolibre.com.ar/MLA-751765547-casco-moto-hawk-htl-dr46-rebatible-lett-store-_JM#position=5&type=item&tracking_id=897c653e-1565-4371-8a4d-b2ea29d09d4d" class="item__info-link item__js-link">
<div class="item__info ">
<div class="item__price ">
<span class="price__symbol">$</span>
<span class="price__fraction">3.725</span>
</div>
<span class="item-installments item__installments--show-card-icon highlighted free-interest item--has-shipping">
<span class="item-installments-text">Hasta 6 cuotas sin interés</span>
</span>
<div class="item__shipping-promise item__shipping highlighted free-shipping">
<span class="text-shipping next_day">Llega gratis el lunes</span>
</div>
<div class="item__brand-logo item__brand-img--ultra-wide">
<span class="item__brand-img-container">
<img src="https://http2.mlstatic.com/D_NQ_NP_796276-MLA31050681849_062019-T.jpg"/>
</span>
</div>
<h2 class="item__title list-view-item-title">
<span class="main-title">Casco Moto Hawk Htl Dr46 Rebatible Lett Store</span>
</h2>
<div class="item__status">
<div class="item__condition">362 vendidos</div>
</div>
</div>
</a>
<form class="item__bookmark-form" action="/search/bookmarks/MLA751765547/make" method="post" id="bookmarkForm" class="bookmark-form">
<button type="submit" class="bookmarks favorite" data-id="MLA751765547">
<div class="item__bookmark">
<div class="icon"></div>
</div>
</button>
<input type="hidden" name="method" value='add'/>
<input type="hidden" name="itemId" value='MLA751765547'/>
<input type="hidden" name="_csrf" value="5fe7b4e6-19d3-42bc-a3bb-15eaeee81f64"/>
</form>
</div>
</li>
<li class="results-item highlighted article grid item-info-height-179">
<div class="rowItem item highlighted item--grid item--has-row-logo new to-item" id="MLA817988063">
<div class="item__image item__image--grid">
<div class="images-viewer" item-url="https://articulo.mercadolibre.com.ar/MLA-817988063-cascos-motos-vega-vflow-motocross-mx-enduro-atv-acces-cam-_JM#position=6&type=item&tracking_id=897c653e-1565-4371-8a4d-b2ea29d09d4d" item-id="MLA817988063">
<div class="carousel">
<ul>
<li>
<a href="https://articulo.mercadolibre.com.ar/MLA-817988063-cascos-motos-vega-vflow-motocross-mx-enduro-atv-acces-cam-_JM#position=6&type=item&tracking_id=897c653e-1565-4371-8a4d-b2ea29d09d4d" class="item-link item__js-link">
<img class='lazy-load' width='284' height='284' alt='Cascos Motos Vega Vflow Motocross Mx Enduro Atv + Acces Cam' src='https://http2.mlstatic.com/cascos-motos-vega-vflow-motocross-mx-enduro-atv-acces-cam-D_NQ_NP_629038-MLA32405702773_102019-W.jpg' />
</a>
</li>
</ul>
</div>
You can use this example "id=\"(MLA[0-9]{6,})\"" to find all the values of id form HTML
Paste the RegEx in here https://regex101.com to see how it works
static void Main(string[] args)
{
var listOfIds = new List<string>();
string html = " id=\"MLA12334566\" id=\"MLA123354566\" id=\"MLA123346566\"";
Regex idRegex = new Regex("id=\"(MLA[0-9]{6,})\"");
var matches = idRegex.Matches(html);
foreach(var match in matches)
{
listOfIds.Add(match.ToString());
}
}

Passing parameters beetween .aspx and .aspx.cs

I am using Visual Studio 2015 Ultimate. I have put a raw HTML web form in my Test.aspx file and want to pass the parameters of form-fields (like : Username, password, mobile no. etc.) from Test.aspx to Test.aspx.cs file. Although, I have written the code for passing the values in the button click function, I can't get the data. I have written "string u = Request.QueryString["username"];" for username field (without quotes) and so on and another line to print the value in that form itself, that is "Response.Write(u);" (without quotes). Here, I can't see the printed values in my form. How can I solve this issue?
Register.aspx file-
<!-- Start Register Section -->
<div id="login-page">
<div class="layer-stretch">
<div class="layer-wrapper">
<div class="layer-container">
<form class="form-container" action="Register.aspx" method="post" enctype="multipart/form-data" runat="server">
<input type="hidden" name="_token" value="15276e55e6cdfa6911f440f75f64501dc97cc6f4a19102dddb4c47f0c4dd1523ad639943996afef209d6a358056f3b3389a9bcb175b7413ef3547589673a2b7d">
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-user-o"></i>
<input class="mdl-textfield__input" type="text" name="fullname" pattern="[A-Z,a-z, ]*" id="register-first-name" runat="server">
<label class="mdl-textfield__label" for="register-first-name">الاسم الكامل<em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال اسم كامل صالح!</span>
</div>
<!--<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-user-o"></i>
<input class="mdl-textfield__input" type="text" name="lastname" pattern="[A-Z,a-z, ]*" id="register-last-name">
<label class="mdl-textfield__label" for="register-last-name">الكنية <em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال الاسم الصحيح!</span>
</div>-->
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-envelope-o"></i>
<input class="mdl-textfield__input" type="text" name="email" pattern="[a-z0-9._%+-]+#[a-z0-9.-]+\.[a-z]{2,3}$" id="register-email" runat="server">
<label class="mdl-textfield__label" for="register-email">البريد الإلكتروني <em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال بريد إلكتروني صحيح!</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-phone"></i>
<input class="mdl-textfield__input" type="text" name="mobile" pattern="[0-9]*" id="register-mobile" runat="server">
<label class="mdl-textfield__label" for="register-mobile">رقم الهاتف المحمول <em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال رقم الجوال صحيح!</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-key"></i>
<input class="mdl-textfield__input" type="password" name="password" id="register-password" runat="server">
<label class="mdl-textfield__label" for="register-password">كلمه السر <em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال كلمة المرور صالحة (الحد الأدنى 6 حرف)!</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon">
<i class="fa fa-key"></i>
<input class="mdl-textfield__input" type="password" name="confirmpassword" id="register-confirm-password" runat="server">
<label class="mdl-textfield__label" for="register-confirm-password">تأكيد كلمة المرور <em> *</em></label>
<span class="mdl-textfield__error">الرجاء إدخال تأكيد كلمة المرور (الحد الأدنى 6 حرف)!</span>
</div>
<div class="mdl-textfield mdl-js-textfield mdl-textfield--floating-label form-input-icon form-bot-check">
<i class="fa fa-question"></i>
<input class="mdl-textfield__input" type="number" name="bot-check" id="register-bot" runat="server">
<label class="mdl-textfield__label" for="register-bot">ما هو 10 زائد 3 =<em>* </em></label>
<span class="mdl-textfield__error">الرجاء إدخال القيمة الصحيحة!</span>
</div>
<!--<div class="login-condition">بالنقر على "إنشاء حساب" فإنك توافق على موقعنا<br />شروط & الظروف</div>-->
<div class="form-submit">
<!-- <button class="mdl-button mdl-js-button mdl-js-ripple-effect button button-primary" name="register" onclick="Submit_Click">إصنع حساب</button>-->
<asp:Button ID="Button1" runat="server" OnClick="Submit_Click" Text="Submit" class="mdl-button mdl-js-button mdl-js-ripple-effect button button-primary" />
<asp:Button ID="Button2" runat="server" Text="Register" class="mdl-button mdl-js-button mdl-js-ripple-effect button button-primary" OnClick="Button2_Click" />
</div>
<div class="login-link">
<span class="paragraph-small">هل لديك حساب؟</span>
تسجيل الدخول
</div>
</form>
</div>
</div>
</div>
</div>
<!-- End Register Section -->
Register.aspx.cs file-
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace MDC_web {
public partial class Register: System.Web.UI.Page {
protected void Page_Load(object sender, EventArgs e) {
}
protected void Submit_Click(object sender, EventArgs e) {
System.Diagnostics.Debug.WriteLine("Register button has been clicked!!");
string fn = String.Format("{0}", Request.Form["fullname"]);
Response.Write("<script language='JavaScript'> alert('jhkjhjk');</script>");
Response.Write(fn);
string em = Request.QueryString["email"];
Response.Write(em);
string mob = Request.QueryString["mobile"];
Response.Write(mob);
string p = Request.QueryString["password"];
string cp = Request.QueryString["confirmpassword"];
/*if (p.Equals(cp))
{
string c = ConfigurationManager.ConnectionStrings["cn"].ConnectionString;
SqlConnection con = new SqlConnection(c);
con.Open();
SqlCommand cmd = new SqlCommand("insert into Register (R_Name, Email, Mobile, R_Pass) values ('" + fn + "','" + em + "'," + mob + ",'" + p + "')", con);
int r = cmd.ExecuteNonQuery();
if (r == 1)
{
Response.Write("<script language='JavaScript'> alert('Registration is successfull!!');</script>");
}
}*/
}
/*protected void Button2_Click(object sender, EventArgs e)
{
Response.Write("<script language='JavaScript'> alert('jhkjhjk');</script>");
//Response.Write(fn);
}*/
}
}
for use form-fields values in .cs you have to do targetting like this
string Username = txtUsername.Value.Trim(); (txtUsername is the name of field in aspx)
string Password = txtPassword.Value.Trim();
string Mobile = txtMobile.Value.Trim();
the query string is used for passing value trough aspx pages not for aspx to cs
You can access asp id from the .aspx in your .aspx.cs.
just give them a unique ID and runat like so:
.aspx
<asp:TextBox runat="server" ID="txtUsername"></asp:TextBox>
.aspx.cs
var username = txtUsername.Text;
this is for receiving the text of the textbox. If you want to set the text then simply change it to txtusername.Text = "test test". You can to this also with asp:labels, asp:button etc.
Check this post for more informations
If you want to do that on a button click just make use of the postback which happens after the click.
.aspx
<asp:TextBox runat="server" ID="txtUsername"></asp:TextBox>
<asp:Button runat="server" ID="btnSumbit" Text="submit"></asp:Button>
.aspx.cs
protected void btnSumbit_Click(object sender, EventArgs e){
var username = txtUsername.Text;
//do username stuff in here
}
if you need a Tutorial for a login form with websforms check one of these:
https://msdn.microsoft.com/en-us/library/ff184050.aspx
https://www.youtube.com/watch?v=QoPABrUknsE
Do not transmit a password, in plain text, via a query string. Set up a https connection for your production site - you can do it free with Let's Encrypt. You say you added a "raw HTML form" - add plain HTML elements but do not add an extra form element because ASPNET can only handle a single form with a runat="server" attribute.
Then, to use plain HTML, just add runat="server" so that you can grab the data on the server side:
Test.aspx:
User Name: <input type="text" name="userName" runat="server">
Test.aspx.cs
string userName = userName.Value.Trim();
UPDATE:
If you're using a master page, why have you got a form tag in the aspx? The master page usually contains the form tag so it looks like you're copying and pasting code from somewhere else. Remove the form tag from your aspx.
Don't pass sensitive information in the URL via a query string. Use a single form tag in your master page, then in your code-behind:
string fName = register-first-name.Value;
You're using ASPNET so there is no point in the pattern attribute. Simply add a Regular Expression validator control.

pass textbox value as parameter to controller route

I'm trying to use a textbox value in controller route and am having some trouble with the syntax. Essentially, I have my end users selecting a file and then submitting the data to the api to process and send the data off. I have working static code below, but can't get the xml path to be dynamically populated via the textbox value.
note that (as far as I can tell) the forward slash at the end of the path is required since there is a dot in the file path.
#using (Html.BeginForm("", "api/food/dummy food file.xml/"))
{
<div class="row">
<div class="col-lg-6">
<label class="control-label">Select File</label>
<div class="input-group">
<label class="input-group-btn">
<span class="btn btn-default">
Browse… <input type="file" style="display: none;" single>
</span>
</label>
<input id="food.filepath" name="food.filepath" type="text" class="form-control" readonly>
</div>
</div>
</div>
<br />
<div>
<button id = "btnSubmit" type="submit" class="btn btn-primary">Submit</button>
</div>
}
I don't what the syntax would be, but I can't get something like the below to work.
#using (Html.BeginForm("", "api/food/" + food.filepath + "/"))
{
<div class="row">
<div class="col-lg-6">
<label class="control-label">Select File</label>
<div class="input-group">
<label class="input-group-btn">
<span class="btn btn-default">
Browse… <input type="file" style="display: none;" single>
</span>
</label>
<input id="food.filepath" name="food.filepath" type="text" class="form-control" readonly>
</div>
</div>
</div>
<br />
<div>
<button id = "btnSubmit" type="submit" class="btn btn-primary">Submit</button>
</div>
}
Because the form is rendered on server and the value food.filepath is on client, you cannot mix them. Changing form action according to client values need to be done on client with javascript.
You can remove the file from action a add it on submit javascript action, for example by changing BeginForm to this:
#using (Html.BeginForm("", "api/food/", FormMethod.Get, new { onSubmit = "this.dataset.act = this.dataset.act||this.action; this.action = this.dataset.act + this['food.filepath'].value" } ))

Email Attachment No Longer Working As Custom Styled ASP:FileUpload Field

I have an asp.net application which allows a file upload and I had this working correctly but now I have custom styled my file upload field it's no longer working and I can't figure out how to get it working again with my new styled field.
OLD HTML
<div class="form-group">
<asp:Label ID="Label3" class="col-md-3 control-label" runat="server" Text="Upload"></asp:Label>
<div class="col-md-3">
<asp:FileUpload ID="fuAttachment" runat="server" class="fileupload"></asp:FileUpload>
</div>
</div>
OLD Code Behind
var file = fuAttachment.PostedFile;
if (file != null && fuAttachment.PostedFile.FileName != "")
{
var content = new byte[file.ContentLength];
file.InputStream.Read(content, 0, content.Length);
Session["FileContent"] = content;
Session["FileContentType"] = file.ContentType;
Session["File"] = fuAttachment.FileName;
Session["AttachmentProvided"] = "Yes";
}
NEW HTML
<div class="fileinput fileinput-new input-group" data-provides="fileinput">
<div class="form-control" data-trigger="fileinput" style="background-color: #ededed">
<span class="fileinput-filename"></span>
</div>
<span class="input-group-addon btn btn-default btn-file">
<span class="fileinput-new">
<span class="glyphicon glyphicon-folder-open" title="Click to select a file."></span>
</span>
<span class="fileinput-exists">
<span class="glyphicon glyphicon-folder-open" title="Click to change the selected file."></span>
</span>
<input type="file" name="...">
</span>
<a href="#" class="input-group-addon btn btn-default fileinput-exists" data-dismiss="fileinput">
<span class="glyphicon glyphicon-remove" title="Remove selected file."></span>
</a>
</div>
I need to store in my session as this populates another page so I need similar code behind as I had
Edit file input to :
<input type="file" id="fuAttachment" runat="server" />
Now you use fuAttachment from codebehind for access uploaded file.
Note: If runat="server" attribute is missing you don't able to control this input from codebehind.

form data passing issue with MVC and Razor

I'm using razor html and attempting to post data to a function. I can get parts of the data to submit and go across just fine but other parts i can not.
#using (Html.BeginForm("Reply", "api/Reply", new { ID = Model.ID, UserName = Model.Username }))
{
<div id="mainArea" class="lightboxContent" style="display: block">
<div class="lightboxText">
<div class="responderTitleLeft">Select Profile: </div>
<div class="responderFormFloat">
<select name="profileSelector" class="select-style">
<option value="Select One" selected>Please Select Your Profile</option>
#foreach (var profile in Model.ProfileModels)
{
<option value="#profile.ProfileID">#profile.ScreenName</option>
}
</select>
</div>
<div class="responderActions">
<div id="Reply" class="TwtiterReply">
<a href="javascript:void(0)">
<img src="/images/engage/actions/reply.png" onclick="toggle('ReplyArea')" title="Reply to message" />
</a>
</div>
<div id="ReplyArea" style="display: none;" class="responderForm">
<div class="responderTitle">Reply</div>
<textarea id="MessageEdit" name="Message" onkeyup="return characterCount(this)" onchange="postChange(this.id, 'messagePreview');" rows="4" cols="50" style="resize: none">#Model.Username</textarea>
<p id="counter"><strong><span id="charCount">140</span></strong> more characters available.</p>
<div class="lightboxButtonsBar">
<input type="button" onclick="toggle('mainArea')" tabindex="3" value="Reply" />
<input type="button" class="cancel" tabindex="4" value="Cancel" />
</div>
</div>
</div>
</div>
</div>
<div id="confirmArea" class="confirmationArea" style="display: none">
<div class="warning">
<p><strong>Warning:</strong></p>
</div>
<div class="warningMessage">
<p>You are posting from #Model.ProfileModels with the message:</p>
<div class="messagePreviewArea" data-form="Reply">
<p>
<textarea id="messagePreview" readonly rows="4" cols="50" style="color: #ffffff; font-size: .9em; background-color: transparent; resize: none; border-color: #808080;"></textarea></p>
<input type="submit" tabindex="3" value="Confirm" />
<input type="button" onclick="toggle('mainArea')" tabindex="3" value="Cancel" />
</div>
</div>
</div>
}
public UserProfile Reply(string ID, string UserName, FormCollection form)
{
var pSelector = form["profileSelector"];
var message = form["Message"];
ApiService msgserv = new ApiService();
UserProfile up = UserProfile.GetFirst(new Guid(pSelector));
messenger.Reply(up.key, UserName, ID, message);
return up;
}
what i'm looking to get out of this form (in order of how it's show) ID, and username (they are provided by the model and i get those no problem.)
The ones i'm having issues with is the profile selector and the text area with the name message.
Can someone point me in the right direction on how to get a textarea and a select into a form?
The reason the select is not providing the model with data is because its name property is not set to corresponing property name in the model. The same goes for the text area. Generally speaking, if you want the form submit to fill those property you use the 'strongly-typed' helper methods, such as DropdownFor and CheckBoxFor. Or you can manually wire those up, try setting the name of the select element to "SelectedProfile" and changing the Reply action to: Reply(string ID,string Username,string SelectedProfile, FormCollection form)
To get from the textarea do something like this on your view #Html.TextArea("messagePreview"); But I would recommend saving things in your model if you can.

Categories