0

I have this select tag where I have to transfer the value of an option to a cs file. I've tried workarounds that includes

runat="server"

but unfortunately it does not work for me. Here is the select code.

<select ng-model="selectedProject" name="selectproject" id="selectproject"
        ng-change="set(); viewfunctions()"
        class="btn btn-default btn-group-justified"
        data-toggle="dropdown">
   <option></option>
   <option ng-repeat="Proj in TaxProjects" value="{{Proj.Data}}">
     {{Proj.Name}}
   </option>
</select>

<input type="text" ng-model="hfsp" id="hfselectproject" name="hfselectproject" />

have tried Hidden input / hidden form

<input type="text" ng-model="hfsp" id="hfselectproject" name="hfselectproject" />

the set function is just an angular function which sets the input to be the value taken from the selection.

$scope.set = function () {
    $scope.hfsp = angular.copy($scope.selectedProject);
}

Viewfunctions is just a function that calls other functions.

$scope.viewfunctions = function () {
    GetAllHeader();
    GetAllType();
    GetAllHeader();
    ClearFields();
}

so here's what I'm trying to do

var getHeaderID = {
    ProjectID: $scope.selectedProject
}

this is from the select tag, I have stored it as an angular variable but am unable to find any ways in introducing it to a .cs file (asp.net/C#).


What would be alternatives for runat="server", where I can access the $scope.selectedProject in a .cs file

georgeawg
  • 48,608
  • 13
  • 72
  • 95
  • 1
    you can write an api and post your data to it. Just call your api from http service and post your data there. That way you will have everything that you want – Praneet Nadkar Apr 22 '19 at 07:19
  • Data hiding problems can be easily avoided by following the "best practice" of [always have a '.' in your ng-models](https://stackoverflow.com/questions/14049480/what-are-the-nuances-of-scope-prototypal-prototypical-inheritance-in-angularjs). – georgeawg Apr 22 '19 at 07:20

0 Answers0