I am trying to access a string from code behind into javascript in aspx page

code behind

  protected void btnSearch_Click(object sender, EventArgs e)
        {            
            List<string> imageList = new List<string>();
            string images="";
            imageList = GetMatchingImages(@"C:\Users\Shahzad\Documents\Visual Studio 2013\Projects\ImageSearchEngine\ImageSearchEngine\Images", txtSearch.Text);

            foreach (var image in imageList)
            {
                images += "\"" + image + "\",";
            }
            images ="["+ images.Substring(0, images.Length - 1)+"]";

        }

        public List<string> GetMatchingImages(string path, string keyword)
        {
            var matches = new List<string>();

            var images = System.IO.Directory.GetFiles(path);

            foreach (var image in images)
            {
                if (image.Contains(keyword))
                {
                    matches.Add(image);
                }
            }

            return matches;
        }

and in the aspx page

<script type="text/javascript">
     var imagesList;
     function getImages()
     {
         return <%=images%>;
     }
     imagesList = getImages();
 </script>

but it is giving error 'images is out of this context' plz help me find out where I am making the mistake

I need to send emails via SMTP to all subscribers of a discussion board. If there a lot (say 1000+) subscribers, I do not want the users who posts a new post to have to wait while the notification emails are being sent out.

At first I thought I could use: System.Net.Mail.SmtpClient.SendMailAsync

But, as this post explains, "Async is not a magic wand that makes the action return the response quicker. Your task (in this case, sending an email) takes as long as it takes and async or not, the action will not return a response until the task has completed." Async is more about being efficient with threads than it is about making a task run faster.

First, is my research about SendMailAsync correct? I don't think it is a correct solution.

Second, what would be a way to achieve my goal? A background task? I've heard of Hangfire. Is something like Hangfire what I need to use? Or could I just use an AJAX call to send the emails?

Btw, I'm using ASP.NET Core and .NET Framework 4.6.1

Below is my code to render Google map along with some drop downs. I have followed multiple tutorials and replicated the same, but in all the cases the code seems to run fine without any exception/error, but finally when the page loads it only consists of the drop downs and the map is not loaded.

It would be of great help if some one could point me int the right direction to let me know what i did wrong.

@model WebTM.Models.MasterDataModel.MastersModel

@{
    ViewBag.Title = "RetailersOnMap";
    Layout = "~/Views/Shared/_Layout.cshtml";
    WebTM.Models.MasterDataModel.MastersModel ModelObj = new WebTM.Models.MasterDataModel.MastersModel();
    ModelObj.Zone = Model.Zone;
    ModelObj.Region = Model.Region;
    ModelObj.Territory = Model.Territory;
    ModelObj.Taluk = Model.Taluk;
}
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCss7ir2FP4Zves_bA-p1VtCXjzg4zzIyw&sensor=true"></script>
<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        Page Header
        <small>Optional description</small>
    </h1>
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Level</a></li>
        <li class="active">Here</li>
    </ol>
</section>
<script src="~/Scripts/jquery-1.11.3.min.js"></script>
<section class="content">
    <script>
        function MapInitialize() {
            debugger;
            var latitude = '@(System.Configuration.ConfigurationManager.AppSettings["Latitude"].ToString())';
            var longitude = '@(System.Configuration.ConfigurationManager.AppSettings["Longitude"].ToString())';

            var mapProp = {
                center: new google.maps.LatLng(6.9167, 79.8473),
                zoom: 10,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            };
            var map1 = new google.maps.Map(document.getElementById("divMapView"), mapProp);
            debugger
            var latlng = new google.maps.LatLng(latitude, longitude);
            var marker = new google.maps.Marker({
                position: latlng,
                map: map1,
                title: 'My Place'
            });

        }
        $(document).ready(function () {
            debugger
            MapInitialize();
            debugger
        });
    </script>
    <div class="col-md-3">

        @Html.LabelFor(m => m.Zone)


        @Html.DropDownListFor(m => m.Zone, Model.Zones, "--Select Zone", new { @class = "form-control" })
        @Html.ValidationMessageFor(m => m.Zone)


        <div>
            @Html.LabelFor(m => m.Region)


            @Html.DropDownListFor(m => m.Region, Model.Regions, "--Select Region", new { @class = "form-control" })
            @Html.ValidationMessageFor(m => m.Region)

        </div>
        <div>
            @Html.LabelFor(m => m.Territory)


            @Html.DropDownListFor(m => m.Territory, Model.Territories, "--Select Territory", new { @class = "form-control" })
            @Html.ValidationMessageFor(m => m.Territory)

        </div>
        <div>
            @Html.LabelFor(m => m.Taluk)


            @Html.DropDownListFor(m => m.Taluk, Model.Taluks, "--Select Taluk", new { @class = "form-control" })
            @Html.ValidationMessageFor(m => m.Taluk)

        </div>
    </div>
    <div id="divMapView" class="col-md-9">

    </div>

</section>

I have the following code:

foreach (var questionGroups in Model.ClientQuestionGroups)
{
        for (var j = 0; j < questionGroups.Questions.Count; j++)
        {       
        <div class="test">
            @Html.HiddenFor(m => m.QuestionAnswers[j].FormAnswerId)
            @Html.HiddenFor(m => m.QuestionAnswers[j].QuestionId)
            @foreach (var alternative in questionGroups.Questions[j].QuestionAlternatives)
            {
                if (alternative.NestedQuestion != null)
                {
                   nestedQuestions.Add(alternative.NestedQuestion);
                }
            }
        </div>
    }

    if (nestedQuestions.Count > 0)
    {
        for (var i = 0; i < nestedQuestions.Count; i++)
        {
            <div class="nestedQuestion">
                @Html.HiddenFor(m => m.QuestionAnswers[i].FormAnswerId)
                @Html.HiddenFor(m => m.QuestionAnswers[i].QuestionId)
                @foreach (var alt in nestedQuestions[i].QuestionAlternatives)
                {
                   @Html.DisplayFor(m => alt.AlternativeText)
                   @Html.RadioButtonFor(m => m.QuestionAnswers[i].AlternativeId, alt.Id, new { @class = "questionAlternative" });
                }
            </div>
         }
    }
}

This generates the following html:

<div class="test">
<input id="QuestionAnswers_0__FormAnswerId" type="hidden" value="00000000-0000-0000-0000-000000000000" name="QuestionAnswers[0].FormAnswerId" data-val-required="Fältet FormAnswerId krävs." data-val="true">
<input id="QuestionAnswers_0__QuestionId" type="hidden" value="427d0a77-b7b7-48b0-956a-28794145e0da" name="QuestionAnswers[0].QuestionId" data-val-required="Fältet QuestionId krävs." data-val="true">
Yes
<input id="QuestionAnswers_0__AlternativeId" class="questionAlternative" type="radio" value="aabf2548-abca-4cb5-89d8-759f2d71be01" nestedquestion="895015c0-2bf0-4c5a-95c9-8d4b29671bf7" name="QuestionAnswers[0].AlternativeId" data-val-required="Fältet AlternativeId krävs." data-val="true">
No
<input id="QuestionAnswers_0__AlternativeId" class="questionAlternative" type="radio" value="91b220dc-3ef3-45a9-8369-dc1e4e2530a8" nestedquestion="" name="QuestionAnswers[0].AlternativeId">
</div>

<div class="nestedQuestion questionDiv">
<p>Testar2</p>
<p>Testar2</p>
<input id="QuestionAnswers_0__FormAnswerId" type="hidden" value="00000000-0000-0000-0000-000000000000" name="QuestionAnswers[0].FormAnswerId">
<input id="QuestionAnswers_0__QuestionId" type="hidden" value="427d0a77-b7b7-48b0-956a-28794145e0da" name="QuestionAnswers[0].QuestionId">
Yes
<input id="QuestionAnswers_0__AlternativeId" class="questionAlternative" type="radio" value="aabf2548-abca-4cb5-89d8-759f2d71be01" name="QuestionAnswers[0].AlternativeId">
No
<input id="QuestionAnswers_0__AlternativeId" class="questionAlternative" type="radio" value="91b220dc-3ef3-45a9-8369-dc1e4e2530a8" name="QuestionAnswers[0].AlternativeId">
</div>

As you can see, the ID-attribute and Name-attribute has the same value/name. I don't want that. I want the first div to be 0, and the nested question div to be 1 and so forth. I know this occurs because It's in the same loop.

I can't quite figure out how to solve this naming schema. Anyone who can push me into the right direction?

I have a model called Customer in my .Net Core application. Within this model I have a set of fields where one of these fields explains the status of the customer. The status is a string type and I want to have a dropdown list in which the user of the application can choose the state of the customer to either active, inactive or processing.

Controller Edit Method:

public async Task<IActionResult> Edit()
{   
    .. 
    List<String> status = new List<String>();
    status.Add("Active");
    status.Add("Inactive");
    status.Add("Processing");
    ViewBag.Status = new SelectList(status);

    return View();
}

Edit View:

<div class="form-group">
    <label asp-for="Status" class="col-md-2 control-label"></label>
    <div class="col-md-10">
        <select asp-for="Status" class="form-control" asp-items="ViewBag.Status">
            <option value="">-- Select Status --</option>
         </select>
         <span asp-validation-for="Status" class="text-danger" />
     </div>
</div>

But for some reason I am getting a

NullReferenceException: Object reference not set to an instance of an object.

Does anyone know what I am doing wrong?

I'm trying to loop through some JSON data and print it to the screen. Here's what the JSON looks like:

JSON data

Using this code, I'm able to loop through the list of category names without any issues:

dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);

foreach (var obj in jsonObj.categories)
{
    <p> <strong> @obj.name </strong> </p>
}

I can't figure out how to loop through subcategories though. I tried this, but I just get Error - Object reference not set to an instance of an object.

foreach (var obj in jsonObj.categories)
{
    <p> <strong> @obj.name </strong> </p>

    foreach (var subcat in jsonObj.subcategories)
    {
        <p> <strong> @obj.name </strong> </p>
    }
}

This question already has an answer here:

Before i ask my question i need to mention that i looked up in the site to solve the problem but i didnt find nothing.

Here is my function :

    public string GetAccessToken(int agencyId)
    {
        string retrunString = null;
        Token fbToken = tokenMgr.Get(agencyId, "FacebookInsights");
        if (String.IsNullOrWhiteSpace(fbToken.AccessToken))  **
            return retrunString;
        else
            return fbToken.AccessToken;
    }

When Token is an object which include a String field name : AccessToken.

When i debug the code and reach the line with the ' ** ' when fbToken.AccessToken is NULL , I get an exception " Object reference not set to an instance of an object."

When i looked up in other threads they suggest to use String.IsNullOrWhiteSpace , but it didnt solve the problem and i keep getting the error.

I would greatly appreciate any help , thanks in advance!

I was getting an error "Request Entity Too Large error- WCF Service". So that I added below lines in the web.config. It is working fine after adding in DEV. I have sent it to the same in PRODUCTION. I am getting an error " The content type text/html; charset=utf-8 of the response message does not match the content type of the binding...."enter image description here

Kindly give me solution.

My goal is to read attachments to a specific format. And I would like to know how. If anyone knows, I appreciate it.

I assigned radiobuttonlist items programatically. i want the radiobuttonlist items are checked/not if checked i want the checked item to compare with another value,if equal increment score else do nothing i have written a code,but while debugging even though i checked the item it is taking null value please help me..

public void assign()
{
    Label2.Text = ques[(int)ViewState["value"]];
    RadioButtonList1.Items.Clear();
    RadioButtonList1.Items.Add(new ListItem(opt1[(int)ViewState["value"]], "0"));
    RadioButtonList1.Items.Add(new ListItem(opt2[(int)ViewState["value"]], "1"));
    RadioButtonList1.Items.Add(new ListItem(opt3[(int)ViewState["value"]], "2"));
    RadioButtonList1.Items.Add(new ListItem(opt4[(int)ViewState["value"]], "3"));
    btn_Submit.Visible = false;
}

public void radiochecked()
{
    if (ViewState["index"] == null)
    {
        ViewState["index"] = 0;
    }
    crctans = (string[])Session["correctanswer"];
    if (RadioButtonList1.SelectedIndex > -1)
    {
        if (crctans[(int)ViewState["index"]] == RadioButtonList1.SelectedItem.Text)
        {
            score = score + 1;
        }
    }
    ViewState["index"] = (int)ViewState["index"] + 1;
    if ((int)ViewState["index"] == 10)
    {
        Session["result"] = score;
    }
}

protected void btn_Next_Click(object sender, EventArgs e)
{
    radiochecked();
}

I used Identity on my web forms. When I get user id through

User.Identity.GetUserId() 

and role

User.IsInRole("Admin")

These methods on my local host working successfully, but on server not working. I don't understand why this not work on my server, help me please.

So I Got a search return to work... however it's not finding the exact entry in the database...

MySqlConnection con = new MySqlConnection(dbConnection);
                MySqlCommand cmd;
                con.Open();
                MySqlDataReader dbReader;
                string cmdText = "SELECT `BanID`, `GUID`, `BanTime`, `Reason`, `BanType`, `Proof` FROM `a3bans`.`bans` WHERE  `GUID` LIKE @pGUID";


                cmd = new MySqlCommand(cmdText, con);

                cmd.Parameters.AddWithValue("@pGUID", "%" + bans.GuidOrIP + "%");

When I search for "e7af78997ef220a557c97a1a4c11e0c2" which is a persons ID, it returns with "fa32f7c456b368e17a278f3b165a550d" which is a completely different persons ID.

If I change my query to WHEREGUID= @prmGUID" it returns as null value.

What am I doing wrong that it wont return the string I am looking for?

i am creating a custom CustomerID (PK) by getting the first double characters of first name and last name taken from textboxes as following:

 string CustomID = (FirstNameTxtbox.Value.Substring(0, 2) + LastNametxtbox.Value.Substring(0, 2));

in order to avoid primary key violation a primary key must not be duplicated so i am trying to:

to get the 5th value which is the int since the primary key is mixed characters and numbers and the first 4 values are characters. and then increase it by 1.

my attempt:

string s =  cmd.CommandText= " Select MAX(CustomerID) from Customers";
string CustomID = (FirstNameTxtbox.Value.Substring(0, 2) + LastNametxtbox.Value.Substring(0, 2) + (Convert.ToInt32(s)+1)) ;

example:

First name= Mak
last name = shima

CustomerID = MASH1

next value if first name and last name has the same first 2 characters of first and last name, then id will be MASH2

I'm using C# along with ajax and I'm having an issue with the collapsible panel. I have a radiobutton list with 10 options and each of those will spit out a different label depending on what was selected based off the selectedindexchanged. I have now put those labels inside of a collapsible panel.

I have set the panel to show based off the selectedindexchanged and added the code to the code behind

CollapsiblePanelExtender1.Collapsed = true; CollapsiblePanelExtender1.ClientState = "true"; (this always puts the panel in a situation where it is ready to be clicked once.

The main issue that I am having is that the panel will be set to open yet none of the labels actually appear. What I get is the panel showing "Click to open -" Even if I change the state of the panel, it never shows the content just that its in the selected view without any of the other parts.

.ascx code

I want blog for my website, but due to some error i am unable to deploy blogengin.net to my site. so i decide to search for an another options, so if there are any options for that then please recommend me !!!

Thanks in advanced.

When I try to play a video uploaded to the FTP server using .net code, it says 'Can't play. Item is unplayable, please reacquire the content. 0xc00d36e5'.

Following is the code that I am using to upload a video file to the FTP server:

Protected Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
    Try
        Dim posFile As HttpPostedFile = Nothing
        posFile = MyFile.PostedFile

        Dim strFileName As String = ""
        strFileName = posFile.FileName

        Dim ext As String = ""
        Dim fileName As String = ""

        ext = System.IO.Path.GetExtension(strFileName)
        fileName = "Vid_" + Now().ToString("yyyyMMddHHmmsss") & ext

        If MyFile.PostedFile.FileName = "" Then
            lblMsg.Text = "Please select a file to upload."
            lblMsg.Visible = True
            lblMsg.CssClass = "error"
        Else
            Dim fileBytes As Byte() = Nothing
            Using fileStream As New StreamReader(posFile.InputStream)
                fileBytes = Encoding.UTF8.GetBytes(fileStream.ReadToEnd())
                fileStream.Close()
            End Using

            Try
                Dim ftp As String = System.Configuration.ConfigurationManager.AppSettings("FtpMediaServerURL") //ftp://www.server.com

                Dim ftpFolder As String = "/media/"

                Dim request As FtpWebRequest = DirectCast(WebRequest.Create(ftp & ftpFolder & fileName), FtpWebRequest)
                request.Method = WebRequestMethods.Ftp.UploadFile

                request.Credentials = New NetworkCredential(System.Configuration.ConfigurationManager.AppSettings("FtpMediaServerUserName"), System.Configuration.ConfigurationManager.AppSettings("FtpMediaServerPassword"))
                request.ContentLength = fileBytes.Length
                request.UsePassive = True
                request.KeepAlive = False
                request.UseBinary = True
                request.ServicePoint.ConnectionLimit = fileBytes.Length
                request.EnableSsl = False

                Using requestStream As Stream = request.GetRequestStream()
                    requestStream.Write(fileBytes, 0, fileBytes.Length)
                    requestStream.Close()
                End Using

                Dim response As FtpWebResponse = DirectCast(request.GetResponse(), FtpWebResponse)
                response.Close()

                lblMsg.Text = "Your file has been uploaded successfully."
                lblMsg.Visible = True
                lblMsg.CssClass = "confirmation"

            Catch ex As Exception
                lblMsg.Text = "An Error occured while uploading your file. Please try again."
                lblMsg.Visible = True
                lblMsg.CssClass = "error"
            End Try
        End If
    Catch ex As Exception
       //Handle Exception
    End Try
End Sub

Can anyone point out what I am doing wrong or else I am missing anything?

I have been tasked to decrypt strings with ASP.net that were encrypted with ColdFusion using the Triple DES algorithm and UUEncode. All of the sites I've found in my research reference Base64 instead of UU and I've even found posts that say ASP.net does not have a method for decoding UUencode values.

Is anyone out there able to provide ASP.net code that performs the same as the following ColdFusion function? VB (preferred) or C# examples would be greatly appreciated.

Decrypt(encrypted_string, key, 'DESEDE', 'UU');

I have a list of strings like following which I fill and group currently like this:

public static List<CustomDTO> mostCommonKeywords { get; set; }

And the list is sorted like following:

  mostCommonKeywords = key.GroupBy(v2 => v2)
                 .Select(g => new CustomDTO { Key = g.Key, Count = g.Count() })
                 .OrderByDescending(e => e.Count).Distinct()
                 .ToList(); 

Where Key is List of strings like following:

var key = new List<string>();

Each string element inside the key list consists of 3 words which I need to merge into 1 in case they are equal (or group them into one, whichever term you prefer more).

The grouping method like above gives me these results:

Samsung Galaxy S7   
Galaxy S7 edge  
Galaxy S7 Edge  
S7 edge SM  
Samsung Galaxy S7   
Samsung Galaxy S7   

As you can see clearly there are duplicates here in this list of strings, and I need the results to look like this:

Samsung Galaxy S7   
Galaxy S7 edge  
S7 edge SM  

So basically wherever a same string occurs, I need to merge it into one...

What am I doing wrong here??

Edit: And here is how the CustomDTO class looks like:

 public class CustomDTO
    {
        public string Key { get; set; } 
        public int Count { get; set; }

        public List<int> Sales = new List<int>(); 
    }

Edit: The thing here is that I'm adding a sale number into each string which consists of 3 words to know which keyword how many sales....

This is how I've done it:

   for (int i = 0; i < filtered.Count; i++)
                {
                    foreach (var triad in GetAllWords(filtered[i]))
                    {
                        var sequence = triad[0] + " " + triad[1] + " " + triad[2];
                        key.Add(sequence + " " + lista[i].SaleNumber);
                    }
                }

This is the part that makes the string "not unique":

 + lista[i].SaleNumber

Edit:

mostCommonKeywords list is a list of CustomDTO object which consists of:

public string Key { get; set; } 
public int Count { get; set; }
public List<int> Sales = new List<int>(); 

And suppose that at the end of everything the list looks like this:

      Key           Sales
Samsung Galaxy S7    5
Galaxy S7 edge       4
Galaxy S7 Edge       4
S7 edge SM           3 
Samsung Galaxy S7    6
Samsung Galaxy S7    7

How can I now find all these duplicates and sum them so that the list looks like following:

Samsung galaxy S7 18 
Galaxy S7 edge 8 
S7 edge SM 3

I'm frustrated. I will try to be specific.

I am kind of a noob when it comes to Identity Authentication, although I managed to finish the entire Identity/Owin setup tutorial from this link

As I said, I managed to finish it in a separate project that I created just to follow the tutorial, and it is working well.

Now, the problem comes when I try to integrate what I learned in a real project WITH THE EXACT SAME CODE THAT I USED IN THE TUTORIAL. A difference in this project is that I have my solution separated in three projects, which are, BusinessLayer, DataObjects, and UI. In this solution, I cannot get passed from the first part of the tutorial, just the "Basics" part, where I should add a user with hardcoded values.

Here is what I have. In the DataObjects project I have an "IdentityModel.cs" where I extend the IdentityUser and IdentityDbContext classes. It looks like this:

public class ApplicationUser : IdentityUser

{
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public int AccountTypeId { get; set; }
    public DateTime CreatedOn { get; set; }
    public string CreatedBy { get; set; }

}

public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
    public ApplicationDbContext() : base("AdsTracker_DevEntities")
    {
    }
}

"AdsTracker_DevEntities" is the name of my connectionstring, which is declared in the web.config of the DataObjects project. Then, in the BusinessLayer project, I have a folder called "ProjectStart". In this folder I have a "IdentityConfig.cs" with the following code:

   public class ApplicationUserStore : UserStore<ApplicationUser>
{
    public ApplicationUserStore(ApplicationDbContext context) : base(context)
    {
    }
}

public class ApplicationUserManager : UserManager<ApplicationUser>
{
    public ApplicationUserManager(IUserStore<ApplicationUser> store) : base(store)
    {
    }
}

Then, I have a controller in the UI project which simply call the "CreateUser" function in the BusinessLayer. The CreateUser function looks like this:

 public async Task<string> AddUser()

    {
        ApplicationUser user;
        ApplicationUserStore Store = new ApplicationUserStore(new ApplicationDbContext());
        ApplicationUserManager userManager = new ApplicationUserManager(Store);
        user = new ApplicationUser
        {
            FirstName = "Lilian",
            LastName = "Cobian",
            AccountTypeId = 1,
            UserName = "test.test",
            Email = "prueba@gfrmedia.com",
            CreatedOn = DateTime.Now

        };

        var result = await userManager.CreateAsync(user, "P@ssword");
        if (!result.Succeeded)
        {
            return result.Errors.First();
        }
        return "User Added";

    }

And that's it. Now, what is the behavior? If I add an user with the user name "test.test", the result of the "await userManager.CreateAsync(user, "P@ssword");" code is "succeeded", but when I go and check the db, nothing was inserted. Now, if I call the function again, and I try to add the very same user, it returns me the error "User Name already taken". Again, I go to the db, and there is no record at all!!! How can it be taken??

And that is the weird part. In the sole project that I created to follow the tutorial, everything works great and the records are added in the db, but when I try in integrate this into my real project, it behaves just as I mentioned.

Could it be because the connectionstring is declared in a web.config of the DataObjects project and not in the BusinessLayer? But then, why and how it "knows" that I already added "test.test" user if there is no record at all in the db????

Please, this is driving me crazy. Any help will be appreciated.

Thank you!!!

I have load qualification in view using list and kept radio button when user make selection of his/her qualification then that values must be store in database in list but list is null when i submit form.here is my code

 @foreach (var item in Model.ListofQualifications)
  {
 <input type="radio" name="Qualification" value="@item.QualificationId" id="chkqulaification_@item.QualificationId" />
 <label for="chkqulaification_@item.QualificationId">@item.QualificationName</label>
 <br />
 }

When user make selection i just want to save the value of selected radio button to database . Here Model.ListofQualifications is bindind data from table of Qualifications

public class TeacherRegisterationViewModel
{
    public List<QualifiationModel> ListofQualifications { get; set; }
}

public class QualifiationModel
{
    public long QualificationId { get; set; }

    public string QualificationName { get; set; }
}

public static TeacherRegisterationViewModel TeacherRegisterhelpers()
    {
        try
        {
            var model = new TeacherRegisterationViewModel
            {
                ListofQualifications = HelperMethods.ListofEntity<Qualification>().Select(q => new QualifiationModel
                {
                    QualificationId = q.ID,
                    QualificationName = q.Name

                }).ToList()
            };
            return model;
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }

    public ActionResult TeacherRegisteration()
    {
        var model = UserManager.TeacherRegisterhelpers();
        return View(model);
    }

I want to be able to add extra education field options while registering a student with the identity framework.

I was thinking to do it in knockoutJs, but that's mainly used to show data from the server to the viewmodel. So now I am looking for a manner to do this in a clean way, because this will be the register page and this will be delicate.

I should be able to add these four textboxed when I click add past school. How can I solve this problem of mine ?

educations

   <div class="col-xs-12">
        <div class="form-group">
            <div class="col-md-6">
                @Html.TextBoxFor(m => m.SchoolName, new { @class = "form-control", @placeholder = Html.DisplayNameFor(n => n.SchoolName) })
            </div>
        </div>
        <div class="form-group">
            <div class="col-md-8">
                @Html.TextBoxFor(m => m.FieldOfStudy, new { @class = "form-control", @placeholder = Html.DisplayNameFor(n => n.FieldOfStudy) })
            </div>
            <div class="col-md-2">
                @Html.TextBoxFor(m => m.From, new { @class = "form-control", @placeholder = Html.DisplayNameFor(n => n.From) })
            </div>
            <div class="col-md-2">
                @Html.TextBoxFor(m => m.Until, new { @class = "form-control", @placeholder = Html.DisplayNameFor(n => n.Until) })
            </div>
        </div>
    </div>