Showing posts with label MVC. Show all posts
Showing posts with label MVC. Show all posts

Saturday, 23 May 2020

asp.net bind drop down list

@Html.DropDownListFor(x => x.itmunit, new List<SelectListItem>
    {
                        new SelectListItem() {Text = "Piece", Value="Piece"},
                        new SelectListItem() {Text = "Box", Value="Box"},
                        new SelectListItem() {Text = "Kg", Value="Kg"},
                        new SelectListItem() {Text = "Litre", Value="Litre"}
    }, new { @class = "form-control" })


Saturday, 11 April 2020

How to use Way2Sms api in C#

public void send(string message, string no)
{

HttpWebRequest myReq =
// (HttpWebRequest)WebRequest.Create("http://ubaid.tk/sms/sms.aspx?uid=" + uid + "&pwd=" + password +
//"&msg=" + message + "&phone=" + no + "&provider=way2sms");
(HttpWebRequest)WebRequest.Create("puturlink = "+"UrUsername"+ "&password=" + "UrPassword" + "&sender=" +"UrSenderID"+ "&to=" +no+ "&message=" + message+ "&reqid=1&format={json|text}&route_id=route+id&callback=Any+Callback+URL&unique=1&sendondate=" +"10-10-2014T05:17:52"+"");
HttpWebResponse myResp = (HttpWebResponse)myReq.GetResponse();
System.IO.StreamReader respStreamReader = new System.IO.StreamReader(myResp.GetResponseStream());
string responseString = respStreamReader.ReadToEnd();
respStreamReader.Close();
myResp.Close();
}

//Button Click code
protected void btn_send_Click(object sender, EventArgs e)
{

send(txt_message.Text, txt_mobile.Text);

ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "alert('sms sent successfully...');", true);

}

Friday, 27 December 2019

How to replacing escape characters from JSON in mvc c#


If the json object is a string, in .Net the escape "\" characters are added,
 should you want to clean up the json string, JObject.Parse({string}) as demonstrated
in the following code snippet cleans up nicely:

var myJsonAsString = "{\"Name\": \"John\", \"LastName\": \"Doe\", \"Age\": 199 }";

var myCleanJsonObject = JObject.Parse(myJsonAsString);
Should give us a clean Json object with the escape characters removed.
{
"Name": "John",
"LastName": "Doe",
"Age": 199
}

redirect to new page from jquery

  function foo(id) { var url = ' @Url . Action ( "Details" , "Branch" , new { id = "__id__" })'...