i have verified my own mobile number with twilio but the number is from a service provider in malaysia. i did the codes to send the sms but i am unable to receive it on my number. do i need a us or canada number or do i have to purchase a number from twilio in order to test the codes. below are the codes:
WebForm1.aspx
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication4.WebForm1" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h4>To Number: </h4>
<asp:TextBox ID="ToNumber" TextMode="password" runat="server"></asp:TextBox>
<h4>SMS Message</h4>
<asp:TextBox ID="Message" runat="server"></asp:TextBox>
<br/>
<br/>
<br/>
<asp:Button ID="SendMessage" OnClick="SendMessage_OnClick" runat="server" Text="Send Message" />
</div>
</form>
</body>
</html>
WebForm1.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using Twilio;
namespace WebApplication4
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void SendMessage_OnClick(object sender, EventArgs e)
{
string ACCOUNT_SID = ConfigurationManager.AppSettings["ACCOUNT_SID"];
string AUTH_TOKEN = ConfigurationManager.AppSettings["AUTH_TOKEN"];
TwilioRestClient client= new TwilioRestClient(ACCOUNT_SID, ACCOUNT_SID);
client.SendSmsMessage("(862) 373-1913", ToNumber.Text, Message.Text);
}
}
}
i have checked with visual studio 2012 that the codes are working but still can't seem to receive the sms. what should i do?
some numbers are not supported by twilio like start with 94,87.
By the it's work with vodafone company numbers.
Please try it.
use:
var result = client.SendSmsMessage("(862) 373-1913", ToNumber.Text, Message.Text);
and take a look at result. If most of the fields are null, look at result.RestException. A common issue is with authentication.
Related
I've searched this error in all google results, but I can't find a solution.
I have this WebForm:
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="LoTest.aspx.cs" Inherits="-.-.-.LoTest" %>
<%# Register TagPrefix="ajax" Namespace="MagicAjax.UI.Controls" Assembly="MagicAjax" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ajax:AjaxPanel ID="ajaxLG" runat="server" AjaxCallConnection="Synchronous">
<asp:Button ID="btnTest" runat="server" CssClass="button" ToolTip="gin." Text="LogIn" OnClick="btnTest_Click"></asp:Button>
</ajax:AjaxPanel>
</div>
</form>
</body>
</html>
Code Behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MagicAjax.UI;
using MagicAjax;
namespace -.-.-
{
public partial class LoTest : AjaxPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnTest_Click(object sender, EventArgs e)
{
AjaxCallHelper.WriteAlert("Test msg");
}
}
}
The web.config:
<httpModules>
<add name="MagicAjaxModule" type="MagicAjax.MagicAjaxModule, MagicAjax"/>
</httpModules>
In the Line “AjaxCallHelper.WriteAlert("Test msg");” throws the error:
Using the AjaxCallHelper write methods outside of an AjaxCall is not allowed.
In IE, just add the site to the compatibility view and that´s all.
Seems like if AjaxMagix.dll works with older elements of the explorer.
In Google Chrome doesn´t work.
I have a question regarding the retrieving data from another website.
My Default.aspx is like this:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" ID="txtInput"></asp:TextBox><br /><br />
<asp:Button runat="server" ID="btnSubmit" Text="Submit"
onclick="btnSubmit_Click" /><br /><br />
<asp:Label runat="server" ID="lblResult1" Text=""></asp:Label>
</div>
</form>
</body>
</html>
and the code behind it like this:
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
System.Net.WebClient wc = new System.Net.WebClient();
lblResult1.Text =
wc.DownloadString(string.Format("http://foo.com/servlet/AccessModule?id={0}&doc_type1=xyz&response=K", txtInput.Text));
}
}
It simply read the data from url above and display it on my page.
For example if i enter 12345678 in the textbox.
The result is something like this:
Now what i would like to do is making that last part of the result clickable. (http://foo.com/report/svc/id=000001DF-D80AB26F-C7D2-4FC3-ADD6-361E6630D572)
Any ideas?
add < a > tag to String.Format
Label S = new Label();
S.Text = wc.DownloadString(string.Format("http://foo.com/servlet/AccessModule?id={0}&doc_type1=xyz&response=K", txtInput.Text));
lblResult1.Text =string.Format("<a href='{0}'></a>", S.Text));
I'm building a product editor webpage using visual C#. I've got an image uploader popping up using fancybox, and I need to get the info from my fancybox once submitted to go back to the first page without clearing any info. I know I need to use ajax but how would I do it?
<%# Page Language="C#" AutoEventWireup="true" CodeFile="uploader.aspx.cs" Inherits="uploader" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
</head>
<body style="width:350px; height:70px;">
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div>
<div style="width:312px; height:20px; background-color:Gray; color:White; padding-left:8px; margin-bottom:4px; text-transform:uppercase; font-weight:bold;">Uploader</div>
<asp:FileUpload id="fileUp" runat="server" />
<asp:Button runat="server" id="UploadButton" text="Upload" onclick="UploadButton_Click" />
<br /><asp:Label ID="txtFile" runat="server"></asp:Label>
<div style="width:312px; height:15px; background-color:#CCCCCC; color:#4d4d4d; padding-right:8px; margin-top:4px; text-align:right; font-size:x-small;">Click upload to insert your image into your product</div>
</div>
</form>
</body>
</html>
CS so far
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Configuration; // Add to page
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data; // Add to the page
using System.Data.SqlClient; // Add to the page
using System.Text; // Add to Page
public partial class uploader : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void UploadButton_Click(object sender, EventArgs e)
{
if (fileUp.HasFile)
try
{
fileUp.SaveAs("\\\\london\\users\\DP006\\Websites\\images\\" +
fileUp.FileName);
string imagePath = fileUp.PostedFile.FileName;
}
catch (Exception ex)
{
txtFile.Text = "ERROR: " + ex.Message.ToString();
}
finally
{
}
else
{
txtFile.Text = "You have not specified a file.";
}
}
}
I have an aspx application. I have defined a dropdownlist in the .aspx file and try to load some data into it from database in .aspx.cs file. But I am getting the error in .aspx.cs as "DropDownList1" does not exists in the current context.
Below is the code:
Wiki.aspx:
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Wiki.aspx.cs" Inherits="FinalProj2._Wiki" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
body { margin: 4%; }
#space1 { height:1em; }
#space2 { height:1em; }
</style>
</head>
<body>
<h1>WIKI</h1>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="DropDownList1" runat="server" Width="100%"></asp:DropDownList>
</div>
<div id="space1"></div>
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack = "true" Height = "150px" Width = "100%"></asp:ListBox>
<div id="space2"></div>
<asp:TextBox ID="TextBox2" runat="server" Height="250px" Width="100%" TextMode="MultiLine"></asp:TextBox>
</form>
</body>
</html>
Wiki.aspx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using FinalProj2.Controllers;
namespace FinalProj2
{
public partial class _Wiki : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FinalProj2.Models.DataClasses1DataContext db = new FinalProj2.Models.DataClasses1DataContext();
Response.Write("<br/>Page.User.Identity.Name: " + Page.User.Identity.Name);
Response.Write("<br/>Page.User.Identity.IsAuthenticated: " + Page.User.Identity.IsAuthenticated);
Response.Write("<br/>Page.User.Identity.AuthenticationType: " + Page.User.Identity.AuthenticationType);
var query = from meet in db.Meets
select meet.Summary;
// where meet.Meeting_ID = (from meet_emp in db.Meet_Emps
//where meet_emp.Employee_Name == Page.User.Identity.Name
//select meet_emp.Meeting_ID)
DropDownList1.DataSource = query;
DropDownList1.DataBind();
}//end
}
}
What could be the possible reason. According to me I feel everything is fine as had used the same way for a list box into another application.
Make sure you have no files that accidentally try to inherit or define the same (partial) Mlass as other files.
Thus no other code behind file should have same signature in FinalProj2 Namespace.
public partial class _Wiki : System.Web.UI.Page
After I click button1, it display 0, why? How can get correct width of a DropDownList control? Thanks!
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
</asp:DropDownList>
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Button1.Text = DropDownList1.Width.Value.ToString();
}
}
It's because the value Width is not set. In html, when the width value is not set, you let the browser choose the size.
Moreover, the asp.net engine only host properties to be able to render the correct Html. If you look at the code of the textbox, you will see that if you put a witdh, it will produces a style="width:yourvalue". ASP.net runs on the server side, so it do not have any idea of the actual size of the control.
If you actually require the client size of the dropdownlist, either specify it explicitly, or use some custom javascript to calculate the actual size of the control, then to pass the calculted size to an hidden field. In the code behind you be able to get the value from the Page.Request.Form collection.
Please clarify your need if you need further explanation.