Switching Language in C#.NET has no impact to site - c#

I have implemented Multi Language Support into my ASP.NET C# followed by this tutorial and set english to my Default language as can be seen here:
When switching to german nothing happens:
In my App_GlobalResource Folder I have to files:
de.language.resx and en.language.resx
My mls.cs file (In the tutorial named BasePage.cs) contains the following code:
public class mls : System.Web.UI.Page
{
public void setLang() {
InitializeCulture();
}
protected override void InitializeCulture()
{
if (!string.IsNullOrEmpty(Request["lang"]))
{
Session["lang"] = Request["lang"];
}
string lang = Convert.ToString(Session["lang"]);
string culture = string.Empty;
// In case, if you want to set vietnamese as default language, then removing this comment
if (lang.ToLower().CompareTo("en") == 0 || string.IsNullOrEmpty(culture))
{
culture = "en-US";
}
if (lang.ToLower().CompareTo("en") == 0 || string.IsNullOrEmpty(culture))
{
culture = "en-US";
}
if (lang.ToLower().CompareTo("de") == 0)
{
culture = "de-AT";
}
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(culture);
base.InitializeCulture();
}
}
And here is my Login.aspx page:
public partial class WebForm3 : mls
{
protected void Page_Load(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Convert.ToString(Session["lang"])))
{
if (Convert.ToString(Session["lang"]) == "en")
{
lbl_Debug.Text = "lang=en";
Session["lang"] = null;
Session["lang"] = "en";
}
else if(Convert.ToString(Session["lang"]) == "de")
{
lbl_Debug.Text = "lang=de";
Session["lang"] = null;
Session["lang"] = "de";
}
}
else
{
lbl_Debug.Text = "nothing";
}
}
}
Here is my aspx code:
<asp:Content ID="Content2" ContentPlaceHolderID="ph_RowMain" runat="server">
<div class="login-box">
<div class="login-logo">
<a href="Start.aspx"><b>
<asp:Literal ID="lt_adminInterfaceHeader" runat="server" Text="<%$Resources:en.language, lt_adminHeader%>"></asp:Literal></b></a>
</div>
<!-- /.login-logo -->
<div class="login-box-body">
<p class="login-box-msg">
<asp:Literal ID="lt_adminInterfaceBox" runat="server" Text="<%$Resources:en.language, lt_adminBox%>"></asp:Literal>
</p>
<div class="form-group has-feedback">
<asp:TextBox ID="tb_email" runat="server" type="email" class="form-control" placeholder="<%$Resources:en.language,tb_email%>"></asp:TextBox>
<span class="glyphicon glyphicon-envelope form-control-feedback"></span>
</div>
<div class="form-group has-feedback">
<asp:TextBox ID="tb_password" runat="server" type="password" class="form-control" placeholder="<%$Resources:en.language, tb_password%>"></asp:TextBox>
<span class="glyphicon glyphicon-lock form-control-feedback"></span>
</div>
<div class="row">
<div class="col-xs-12">
<asp:Button ID="btn_signIn" runat="server" Text="<%$Resources:en.language, btn_signIn%>" type="submit" class="btn btn-primary btn-block btn-flat" />
</div>
<!-- /.col -->
</div>
</div>
<!-- /.login-box-body -->
</div>
<!-- /.login-box -->
Hope somebody can help.

You have the name of the files wrong. you have de.lanuage.rex but, according to the article you referred, it requires format anyname.language.de.resx.

When you are trying to localize your website, name of the resourse files matters a lot.
your resourse files name should follow the below format
FileNameYouWant.language-culture.resx
in case you do not specify the language-culture i.e if your filename is like this
FileNameyouWant.resx then by default it will take english language(language-culture='en').
example:German language resourse file name=FileNameYouWant.de.resx
French language resourse file name=FileNameYouWant.fr.resx

Related

Why is the textbox in my ASP.NET webform always empty

This is my markup:
<%# Page Title="" Language="C#" MasterPageFile="~/User/Default.Master" AutoEventWireup="true" CodeBehind="Consulation.aspx.cs" Inherits="PetShop.User.Consulation" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script>
window.onload = function () {
var second = 5;
setTimeout(function () {
document.getElementById("<%=lblMsg.ClientID%>").style.display = "none";
}, second * 1000)
}
</script>
<link href="../CSSandJS/StyleCss/consulation.css" rel="stylesheet" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<!-- Slider -->
<section id="Slider">
<div class="aspect-ratio-169">
<img src="../CSSandJS/images/bg_1.jpg" alt="">
<img src="../CSSandJS/images/bg_2.jpg" alt="">
<img src="../CSSandJS/images/bg_3.jpg" alt="">
<img src="../CSSandJS/images/bg_4.jpg" alt="">
</div>
<div class="dot-container">
<div class="dot active"></div>
<div class="dot"></div>
<div class="dot"></div>
<div class="dot"></div>
</div>
</section>
<!-- End Slider -->
<!-- Free Consulation -->
<section class="contact">
<div class="container-contact">
<h1>Đặt lịch hẹn</h1>
<div class="row">
<div class="contact-img">
<img src="../CSSandJS/images/bg_1.jpg" alt="" width="400">
</div>
<div class="input-infor">
<div class="form">
<div class="dbl-field">
<asp:DropDownList ID="ddlCategory" runat="server" CssClass="form-control option field-mail listOp" DataSourceID="SqlDataSource1" DataTextField="TENDV" DataValueField="MADV" AppendDataBoundItems="true">
<asp:ListItem Value="0">Chọn danh mục</asp:ListItem>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:cs %>" SelectCommand="SELECT [MADV], [TENDV] FROM [DICHVU]"></asp:SqlDataSource>
</div>
<div class="dbl-field">
<div class="field-mail">
<asp:TextBox ID="txtEmail" runat="server" CssClass="form-control input" placeholder="Nhập email" required></asp:TextBox>
<i class="ri-mail-line"></i>
</div>
</div>
<div class="dbl-field">
<div class="field">
<asp:TextBox ID="txtNameAcc" runat="server" CssClass="form-control input" placeholder="Nhập tên"></asp:TextBox>
<i class="ri-user-line"></i>
</div>
<div class="field">
<asp:TextBox ID="txtSDT" runat="server" CssClass="form-control input" placeholder="Nhập số điện thoại" MaxLength="11"></asp:TextBox>
<i class="ri-phone-line"></i>
</div>
</div>
<div class="dbl-field">
<div class="field">
<asp:TextBox ID="txtNgay" runat="server" CssClass="form-control input" TextMode="Date"></asp:TextBox>
<i class="ri-calendar-2-line"></i>
</div>
<div class="field">
<asp:TextBox ID="txtTime" runat="server" CssClass="form-control input" placeholder="Nhập giờ hẹn" MaxLength="5" TextMode="SingleLine"></asp:TextBox>
<i class="ri-time-line"></i>
</div>
</div>
<div class="message">
<asp:TextBox ID="txtDescription" runat="server" CssClass="form-control textarea" placeholder="Tin nhắn" TextMode="MultiLine"></asp:TextBox>
<i class="ri-message-2-line"></i>
</div>
<div class="button-area">
<asp:Button ID="Add" runat="server" Text="Gửi lịch hẹn" class="btn btn-primary button" OnClick="Add_Click"/>
<asp:Label ID="lblMsg" runat="server" Visible="false"></asp:Label>
<%--<asp:linkbutton id="submitcal" runat="server" cssclass="btn btn-primary button" OnClick="Add_Click">gửi lịch hẹn</asp:linkbutton>--%>
</div>
</div>
</div>
</div>
</div>
</section>
<!-- End Free Consulation -->
</asp:Content>
The textbox doesn't get any value when I debug the program.
I have tested the stored procedure in SQL Server and it works fine. But the data returned from the SQL code is empty.
My button submit code:
namespace PetShop.User
{
public partial class Consulation : System.Web.UI.Page
{
SqlConnection con;
SqlCommand cmd;
protected void Page_Load(object sender, EventArgs e)
{
}
private void clear()
{
txtEmail.Text = string.Empty;
txtDescription.Text = string.Empty;
txtNameAcc.Text = string.Empty;
txtSDT.Text = string.Empty;
txtNgay.Text = string.Empty;
txtTime.Text = string.Empty;
ddlCategory.ClearSelection();
}
protected void Add_Click(object sender, EventArgs e)
{
string actionName = string.Empty;
bool isValidToExcute = true;
con = new SqlConnection(Connection.GetConnectionString());
cmd = new SqlCommand("Add_KHaddLH", con);
cmd.Parameters.AddWithValue("#Action", "INSERT4KH");
cmd.Parameters.AddWithValue("#MaDv", ddlCategory.SelectedValue);
cmd.Parameters.AddWithValue("#EMail", txtEmail.Text.Trim());
cmd.Parameters.AddWithValue("#Ten", txtNameAcc.Text.Trim());
cmd.Parameters.AddWithValue("#Sdt", txtSDT.Text.Trim());
cmd.Parameters.AddWithValue("#NgayHen", txtNgay.Text.ToString());
cmd.Parameters.AddWithValue("#GioHen", txtTime.Text.Trim());
cmd.Parameters.AddWithValue("#GhiC", txtDescription.Text.Trim());
if (isValidToExcute)
{
cmd.CommandType = CommandType.StoredProcedure;
try
{
con.Open();
cmd.ExecuteNonQuery();
actionName = "gửi";
lblMsg.Visible = true;
lblMsg.Text = "Lịch hẹn " + actionName + " thành công!";
lblMsg.CssClass = "alert alert-success";
clear();
}
catch (Exception ex)
{
lblMsg.Visible = true;
lblMsg.Text = "Lỗi !!!" + ex.Message;
lblMsg.CssClass = "alert alert-danger";
}
finally
{
con.Close();
}
}
}
}
}
I think the error lies in the page reload, because when submitting it will delete all the data in the textbox and then enter.
I've tried adding some commands to the button but still can't handle that it keeps losing textbox data.
I update code behind and markup.
Support me,
Thank.
Ok, so that helps a boatload.
if we have this code:
protected void Add_Click(object sender, EventArgs e)
{
string actionName = string.Empty;
bool isValidToExcute = true;
Debug.Print(txtEmail.Text);
output:
So, you might want to put a break point in, or simple add some debug.prints, and see which text box controls are "empty". But, just looking at what you have, those text boxes should be ok.
And including page-load, shows that you not say running the "clear" routine you have. (so, having included the page load event eliminates about 100 possible issues here. This is VERY much why posting some of your code allows the public here to eliminate a 100 "back and forth" suggestions.) So, for example, had you included "clear" routine in page load, then of course page load fires each and every time BEFORE a button click event, so code in page load is VERY OFTEN suspect here. But, since you don't have code in page load event, we scratch that off the table.
So, far, the controls look to have values, but I suggest you add a break point, or some debug.prints as per above to be 100% sure that the controls in fact do not have values.
Also, just pasting in some of the markup, we see things like this:
So, you do have stray "garbage" in a number of places. (not good).
As it stands, with the posted markup, I MOST certainly do get/see/have/enjoy/observe that the text boxes are intact, do have values.
Given we can't re-produce your issue?
I suggest creating a blank new page, drop in some of those controls, and try a test button - (don't even bother with the database save code - we NOT gone that far down the debugging road just yet).
So, only thing so far?
Are you 100% sure the text boxes don't have values, and you tested this BEFORE any of the database save code runs?
and do remove the stray "required" markup in that txtEmail box, the editor even HONKS OUT AT YOU that the markup is bad as per above screen shot.
In fact, drop in another button on the form, and its only job would be to debug print out the text boxes - does that work?
As it stands now, you don't have a re-producable error, and the community in general here has not, does not see your error, nor are we the viewing public EVEN able to re-produce that these text boxes don't have values.
As a result, there information we don't have to re-produce the error.
I suggest building a page with just the txtEmail that is blank, and a simple button. if that works, then start adding markup from that other page until it stops working, since we here can't re-produce your issue with the provided code and markup you have provided.
And, since you using a master page, then check if page load in master page has any code that runs on page load.

File is getting saved when uploaded 2nd time

<div class="PriceCalculatorForm">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="PnlSaveData" runat="server">
<div class="form-group">
<div class="col-md-1"></div>
<label class="control-label col-sm-4">Upload Image</label>
<div class="col-sm-4">
<asp:FileUpload ID="ImageFileUploader" runat="server" />
<asp:Label ID="lblMsg" runat="server" Text=""></asp:Label>
</div>
<div class="col-md-2">
<asp:Button ID="btnImageUpload" runat="server" Text="Upload Image" OnClick="btnImageUpload_Click" CssClass="btnSearch" />
</div>
<div class="col-md-1"></div>
</div>
</asp:Panel>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="btnImageUpload" />
</Triggers>
</asp:UpdatePanel>
</div>
protected void btnImageUpload_Click(object sender, EventArgs e)
{
if (ImageFileUploader.HasFile)
{
string FileExtension = Path.GetExtension(ImageFileUploader.FileName);
if (FileExtension.ToLower() == ".jpg" || FileExtension.ToLower() == ".jpeg" || FileExtension.ToLower() == ".png" || FileExtension.ToLower() == ".gif")
{
string FileName = ImageFileUploader.FileName;
//Saving the file
ImageFileUploader.SaveAs(Server.MapPath("~/Images/" + FileName));
}
}
else
{
lblMsg.Text = "Please select file to upload";
lblMsg.ForeColor = System.Drawing.Color.Red;
}
}
Problem:
After running code when file is uploaded for first time it goes in else part of code, but the same file when uploaded again it work properly and file is saved at specified location. This is happening every time of execution. I am not getting what is going wrong.
Please any one can guide me on this?
change your form tag to this if you are mot using like this:
<form action="" method="post" enctype="multipart/form-data" id="form">
// your code
</form>
Everyone thank you for your support. Finally I got the solution and end up by adding this.Page.Form.Enctype = "multipart/form-data" under Page_Load Event.
protected void Page_Load(object sender, EventArgs e)
{
this.Page.Form.Enctype = "multipart/form-data";
}

Cannot add class to aspx.cs file

I have 2 files in my web site project, Translator2.aspx and Translator2.aspx.cs. I want to add new class (Erwin:Translator2) to my Translator2.aspx.cs file. However it was error like this :
Severity Code Description Project File Line Suppression State
Error 'translator2_aspx' does not contain a definition for 'Switch'
and no extension method 'Switch' accepting a first argument of type
'translator2_aspx' could be found (are you missing a using directive
or an assembly reference?)
C:\Users\erwin.surya\Documents\Visual
Studio 2017\WebSites\WebSite1\Translator2.aspx 33
Here is my Translator2.aspx code:
<%# Page Language="C#" Async="true" AutoEventWireup="true" CodeFile="Translator2.aspx.cs" MasterPageFile="~/Site.Master" Inherits="Translator2" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="English" CssClass="col-md-2 control-label">English</asp:Label>
<div class="col-md-10">
<asp:TextBox Height="79px" TextMode="MultiLine" Width="452px" runat="server" ID="English" CssClass="form-control" />
</div> </div>
<div class="col-md-offset-2 col-md-10">
<asp:Button runat="server" OnClick="Submit" Height="39px" Width="100px" Text="Translate" CssClass="btn btn-default" />
</div>
<div class="col-md-offset-2 col-md-10">
<asp:Button runat="server" OnClick="Switch" Height="39px" Width="100px" Text="Switch" CssClass="btn btn-default" />
</div>
<br /><br /><br />
<div class="form-group">
<asp:Label runat="server" AssociatedControlID="Japanese" CssClass="col-md-2 control-label">Japanese</asp:Label>
<div class="col-md-10">
<asp:TextBox Height="79px" TextMode="MultiLine" Width="452px" runat="server" ID="Japanese" CssClass="form-control" />
</div></div>
<br /><br />
<asp:PlaceHolder runat="server" ID="ErrorMessage" Visible="false">
<p class="text-danger">
<asp:Literal runat="server" ID="FailureText" />
</p>
</asp:PlaceHolder>
</asp:Content>
Here is my Translator2.aspx.cs code:
partial class Translator2 : Page
{
public async void Submit(object sender, EventArgs e)
{
string key = "92fcf1387f844a8";
var authTokenSource = new AzureAuthToken(key.Trim());
string authToken;
try
{
authToken = await authTokenSource.GetAccessTokenAsync();
}
catch (HttpRequestException)
{
if (authTokenSource.RequestStatusCode == HttpStatusCode.Unauthorized)
{
Console.WriteLine("Request to token service is not authorized (401). Check that the Azure subscription key is valid.");
return;
}
if (authTokenSource.RequestStatusCode == HttpStatusCode.Forbidden)
{
Console.WriteLine("Request to token service is not authorized (403). For accounts in the free-tier, check that the account quota is not exceeded.");
return;
}
throw;
}
string output = "";
string text = English.Text;
string uri = "https://api.microsofttranslator.com/v2/Http.svc/Translate?text=" + HttpUtility.UrlEncode(text) + "&from=" + "en" + "&to=" + "ja";
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Headers.Add("Authorization", authToken);
using (WebResponse response = httpWebRequest.GetResponse())
using (Stream stream = response.GetResponseStream())
{
DataContractSerializer dcs = new DataContractSerializer(Type.GetType("System.String"));
string translation = (string)dcs.ReadObject(stream);
Console.WriteLine("Translation for source text '{0}' from {1} to {2} is", text, "en", "ja");
Console.WriteLine(translation);
output = translation;
}
Japanese.Text = output;
}
class Erwin : Translator2
{
string from, to;
public void SwapStrings(string s1, string s2)
{
string temp = s1;
s1 = s2;
s2 = temp;
from = s1;
to = s2;
testing.Text = from;
testing1.Text = to;
}
protected void Switch(object sender, EventArgs e)
{
string str1 = testing.Text;
string str2 = testing1.Text;
System.Console.WriteLine("Inside Main, before swapping: {0} {1}", str1, str2);
SwapStrings(str1, str2);
}
}
Do you have any idea why I can't add Erwin:Translato2 class? everything works fine before I add the class. Did I miss something?
The Switch method is in a different class than the class that is powering your aspx page. If you want switch to be some kind of utility method, you should create a new class, maybe Erwin in a completely separate file (Erwin.cs), and have a switch method inside that that is public and probably static. I also note that switch doesn't return anything, so not sure what you are trying to accomplish with it.
The OnClick handler for your button should be in the code behind -- ie in the Translator2 class. Inside this handler, you could call Erwin.Switch().

ASP.NET Send variable in code behind

**ASPX CODE** this is the aspx code
<% for (int i = 0; i < pricePageObj.cartItemsgetset; i++)
{ %>
<div class="row">
<div class="col-md-1 ">
<% Response.Write(i + 1); %>
</div>
<div class="col-md-2 ">
<% Response.Write(svcID[i]); %>
</div>
<div class="col-md-2 ">
<% Response.Write(svcName[i]); %>
</div>
<div class="col-md-3 ">
<% Response.Write(svcDesc[i]); %>
</div>
<div class="col-md-2 ">
<% Response.Write(svcCharges[i]); %>
</div>
<div class="col-md-1 ">
<asp:Button CssClass="btn btn-danger" runat="server" Text="Remove" CommandArgument="dont know how to pass i here" OnCommand="onRemove" />
</div>
</div>
<%} %>
Let's say i=0 ; i<5; i++. so for loop will go for 5 times. so i want to send i as a parameter in the code behind to read the value of i.
C# CODE code behind
public void onRemove(object sender, CommandEventArgs e)
{
try
{
string indexx = Convert.ToString(e.CommandArgument);
System.Diagnostics.Debug.WriteLine("String index = " + indexx);
}
catch (Exception ex)
{
}
}
I want to send that 'i' index in the code behind. Any help?
When i clicked on the button, i want to read that i in the onRemove event.
any help?
Here is how we normally display a collection inside Bootstrap divs in ASP.NET Web Form. If we want to manipulate individual row, we use ItemDataBound event.
It seems a lot of code compare to your original question, but this is a recommended approach in ASP.NET Web Form.
<asp:ListView runat="server" ID="ListView1"
ItemPlaceholderID="ItemPlaceholder"
OnItemDataBound="ListView_ItemDataBound">
<LayoutTemplate>
<asp:Panel runat="server" ID="ItemPlaceholder"></asp:Panel>
<asp:DataPager runat="server" ID="DataPager" PageSize="3">
<Fields>
<asp:NumericPagerField ButtonCount="5" PreviousPageText="<" NextPageText=">" />
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<div class="row">
<div class="col-md-1">
<%# Eval("Id") %>
</div>
<div class="col-md-2">
<%# Eval("Name") %>
</div>
<div class="col-md-1">
<asp:Button CssClass="btn btn-danger" runat="server" Text="Remove"
CommandArgument='<%# Eval("Id") %>' ID="RemoveButton"
OnCommand="RemoveButton_Command" />
</div>
</div>
</ItemTemplate>
</asp:ListView>
Code Behind
public class User
{
public int Id { get; set; }
public string Name { get; set; }
}
public partial class About : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
ListView1.DataSource = new List<User>
{
new User {Id = 1, Name = "John"},
new User {Id = 2, Name = "Marry"},
new User {Id = 3, Name = "Nancy"},
new User {Id = 4, Name = "Eric"},
};
ListView1.DataBind();
}
}
protected void RemoveButton_Command(object sender, CommandEventArgs e)
{
int id = Convert.ToInt32(e.CommandArgument);
}
protected void ListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
if (e.Item.ItemType == ListViewItemType.DataItem)
{
User user = e.Item.DataItem as User;
}
}
}
<% Response.Write(i + 1); %>
By doing this, you are passing i to the Response.Write method.
You should be able to just write a method in your code behind.
Code behind sample method:
protected int Foo(int bar){
//do something with bar
return bar;
}
You should be able to do this on the .aspx page now:
<% Response.Write(Foo(1) + 1); %>
You can access all of the methods in your code behind by putting the below line at the top of your page, replacing MyCoolPage with your page name. This line should be added for you automagically, though, when you create a web form page:
<%# Page CodeBehind="MyCoolPage.aspx.cs" Inherits="MyCoolPage" Language="C#" %>
Instead of doing what you are doing with your button, just add an OnClick event instead of what you are doing now, as follows:
<asp:Button CssClass="btn btn-danger" runat="server" Text="Remove" OnClick="DoSomethingCool(i) />
DoSomethingCool:
protected void DoSomethingCool(int index){
try
{
System.Diagnostics.Debug.WriteLine("index = " +
index);
}
catch (Exception ex)
{
}
}

How can I modify an angular ng-model from my C# code behind file?

The problem is, if I add the directive ng-model to any of my asp:TextBox's, then I cannot change their value from my code behind file. The ng-model is tied to vm.Company, which I cannot access from my code behind. I would do this all in javascript, but I do not know how to get EPiServerProfile.current outside of .NET.
User Control (.ascx) :
<div class="container" data-ng-app="app">
<div data-ng-controller="membershipsettingscontrol as vm" class="row">
<div class="row">
<div class="span4">
<label for="txtCompanyName">Company Name:</label>
</div>
<div class="span8">
<asp:TextBox runat="server" ID="txtCompanyName" data-ng-model="vm.Company" data-ng-disabled="false" />
</div>
</div>
</div>
</div>
My Code behind file (.cs):
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
currentProfile = EPiServerProfile.Current;
txtCompanyName.Text = currentProfile.Company;
}
}
app.js:
(function () {
'use strict';
var controllerId = 'membershipsettingscontrol';
angular.module('app').controller(controllerId, ['$scope', '$location', 'datacontext.sbcountry', 'datacontext.sbstates', 'datacontext.sbcontact', admin]);
function admin($scope, $location, sbcountrydatacontext, sbstatesdatacontext, sbcontactdatacontext) {
var vm = this;
vm.title = 'Job Add';
vm.states = [];
vm.Address = {};
vm.getStates = getStates;
vm.submit = submit;
getCountries();
pageLoad();
function getCountries() {
return sbcountrydatacontext.getCountries().then(function (httpResults) {
vm.countries = httpResults.data.Countries;
});
}
function getStates(country) {
return sbstatesdatacontext.getStates(country).then(function (httpResults) {
vm.states = httpResults.data.States;
});
}
function submit(data) {
return sbcontactdatacontext.updateContact(data);
}
}
})();

Categories