Trying to read XML file but he is always the same - asp.net

I have a xml file that changed when i update some values, and i'm trying to read it from javascript in asp.net.
But once i run the project, every time i try to read the xml file, the file is the same from the begining...
this is my javascript code that i have in server side
script = "function OnClientDragEnd(dock, args)" +
"{" +
" req = false; " +
" var isIE = false;" +
// branch for native XMLHttpRequest object
" if(window.XMLHttpRequest && !(window.ActiveXObject)) {" +
" try {" +
" req = new XMLHttpRequest();" +
" } catch(e) {" +
" req = false;" +
" }" +
// branch for IE/Windows ActiveX version
" } else if(window.ActiveXObject) {" +
" try {" +
" req = new ActiveXObject('Msxml2.XMLHTTP');" +
" } catch(e) {" +
" try {" +
" req = new ActiveXObject('Microsoft.XMLHTTP');" +
" } catch(e) {" +
" req = false;" +
" }" +
" }" +
" }" +
" if(req) {" +
" req.onreadystatechange = function(){processReqChange(dock,args)};" +
" req.open('GET', 'Config.xml', false);" +
" req.send('');" +
" }" +
"}" +
"function processReqChange(dock,args) {" +
// only if req shows "loaded"
" if (req.readyState == 4) {" +
// only if "OK"
" if (req.status == 200) {" +
// ...processing statements go here...
" var iiii = req.responseXML.getElementsByTagName('Object');alert(iiii.length);" +//Value stays the same after xml have changed
" } else {" +
" alert('There was a problem retrieving the XML data: ' + req.statusText);" +
" }" +
" }" +
"}";
ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "PositionChanged", script, true);
This code is in http://developer.apple.com/internet/webcontent/xmlhttpreq.html
What do i need to do for get always the xml file updated

IE has a habit of caching AJAX requests. Try something like this:
Date d = new Date();
req.open('GET', 'Config.xml?_' + d.getTime(), false);
this will append the number of milliseconds since 1970 to each request, forcing IE to fetch a new version of the XML.

Related

I am getting android.database.sqlite.SQLiteException "SELECTamountFROMnilanjan_tableWHEREName": syntax error (code 1):

I am getting android.database.sqlite.SQLiteException "SELECTamountFROMnilanjan_tableWHEREName": syntax error (code 1):
public Cursor getItemID(String name)
{
SQLiteDatabase db =this.getWritableDatabase();
String query = "SELECT" + COL_3 + "FROM" + TABLE_NAME +"WHERE" + COL_2 + " = '" + name + "'" ;
Cursor data = db.rawQuery(query,null);
return data;
}
"SELECTamountFROMnilanjan_tableWHEREName" from your error message is the result of your concatination to be executed as query.
you need to add spaces between your keywords to create a valid query.:
"SELECT " + COL_3 + " FROM " + TABLE_NAME + " WHERE " + COL_2 + " = '" + name + "'" ;

Url.Action to Html.Raw

I have this code om my View. And this is work good.
... onclick="location.href = '#Url.Action("Plan", "Care", new {Area = "HomeC"})'"><img src="~/Content/images/dash/Care.PNG"
How Can I do the same code with Html.Raw?
I tried this
grid.Column(columnName: "Name", header: "", format: #<text>#(item.ListStatus == 1 ? Html.Raw("<button class='btn btn-default btn-plan' title='Care' onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''>" +
"<img src='/Content/images/dash/Care.PNG' class='img-plan' data-interlocutorid=" + item.UserId + " " + "data-interlocutorname=" + item.Name + " " + ">" +
"</button>") : Html.Raw(""))
</text>),
With image all good, but link doesn't work.
Change the single-quotes around your Url.Action(...) to double-quotes instead.
That is, change this portion:
onclick='location.href = " + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "''
to this:
onclick='location.href = " + "\"" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "\"'
This will change the rendered output from:
onclick='location.href = '/Care/Plan?Area=HomeC''
to:
onclick='location.href = "/Care/Plan?Area=HomeC"'
onclick=" + "location.href=" + "'" + Url.Action("Plan", "Care", new {Area = "HomeC"}) + "'" + ">"
This is work good.

Want to get data from other website in asp.net

I am trying to get data from other website using NuGet but its not get anything.
var aTags showing null value.
var getHtmlWeb = new HtmlWeb();
var document = getHtmlWeb.Load("https://www.google.com");
var aTags = document.DocumentNode.SelectNodes("//a");
int counter = 1;
if (aTags != null)
{
foreach (var aTag in aTags)
{
Label1.Text += counter + ". " + aTag.InnerHtml + " - " + aTag.Attributes["href"].Value + "\t" + "<br />";
counter++;
}
}

why onserverclick does not work in href in asp.net

I have problem that onserverclick attribute does not work ,the method which assigned to it does not trigger.
string strTr = "";
for (int i = 0; i < adminuserlist.Count; i++)
{
strTr += string.Format("<tr id=\"tr\">" +
" <td>{0}</td> " +
" <td>{1}</td> " +
" <td>{2}</td> " +
" <td>{3}</td> " +
" <td>{4}</td> " +
" <td>{5}</td> " +
" <td>{6}</td> " +
"<td class=\"col-lg-2\">" +
" <a href=\"#\" id=" + i +
"runat=\"server\" onServerClick=\"MyFuncion_Click\"
class=\"table-icontoolbar\" data-toggle=\"tooltip\" data-
placement=\"top\" title=\"Edit\"> " +
" <img
src=\"../images/icon-edit.png\"></a> " +
" <a href=\"#\"
runat=\"server\" onClick=\"bll();\"
onServerClick=\"MyFuncion_Click2\" class=\"table-icontoolbar\"
data-toggle=\"tooltip\" data-placement=\"top\"
title=\"Delete\">" +
" <img
src=\"../images/icon-delete.png\"></a>" +
" </td> " +
" </tr>",
adminuserlist[i].AdminUserName,
adminuserlist[i].AdminUserPassword,
adminuserlist[i].AdminUserEmail,
adminuserlist[i].AdminUserType, adminuserlist[i].IsActive,
adminuserlist[i].isDeleted,
adminuserlist[i].CreatedOn);
tbodyAdminUserView.InnerHtml = strTr;
}
and this the function which should be triggered:
public void MyFuncion_Click(Object sender, EventArgs e)
{
Label1.Text = "vvvv";
}

Web forms : sending image into email not displaying in outlook?

I'm sending an image through web form the image is displayed well into gmail ,yahoo etc.
But i'm not able to view that image when I send it on Outlook
what would be wrong please help.
Code:
//Variable mg have a html code with 'cid:uniqueId1’ calls image from function SendMail12
void birthday()
{
Coonection con = new Coonection();
sql = "select es.PORTNO,es.SERVERNAME,es.EMAILID,es.PASSWORD,e.efrom,e.SerNo,e.eto,e.ecc,e.emessage,e.eflag,e.EmpID,e.FIRSTNAME,e.LASTNAME,e.DeptName,e.FromDate,e.Todate,e.Reason from EMAILSETTING es,EmailSender e";
SqlDataAdapter da = new SqlDataAdapter(sql, con.GetConnection());
DataSet ds = new DataSet();
da.Fill(ds);
string sub = "Message";
int portnum, n,sn;
string servername1, passwo, account, t, ecc, mg, flage,mg2;
sql = "select count(srno)from EmailSender";
SqlCommand cmd = new SqlCommand(sql, con.GetConnection());
// dr = cmd.ExecuteReader();
n = Convert.ToInt32(cmd.ExecuteScalar());
//while (i)
//{
for (int i = 0; i < n; i++)
{
if (ds.Tables[0].Rows.Count > 0)
{
portnum = Convert.ToInt32(ds.Tables[0].Rows[0]["PORTNO"].ToString());
servername1 = ds.Tables[0].Rows[0]["SERVERNAME"].ToString(); //Table(0).Rows(0)("SmtpServerName").ToString();
account = ds.Tables[0].Rows[0]["EMAILID"].ToString();
passwo = ds.Tables[0].Rows[0]["PASSWORD"].ToString();
t = ds.Tables[0].Rows[i]["eto"].ToString();
ecc = ds.Tables[0].Rows[i]["ecc"].ToString();
mg2 = ds.Tables[0].Rows[i]["emessage"].ToString();
flage = ds.Tables[0].Rows[i]["eflag"].ToString();
sn = Convert.ToInt32(ds.Tables[0].Rows[i]["SerNo"].ToString());
if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
{
mg = " <html> " +
"<body background= 'meet.jpg'>" +
"<head> " +
"<title>Untitled Document</title> " +
"<meta content='text/plain; charset=us-ascii' http-equiv='Content-Type' />" +
"<style type='text/css'> " +
".style1 { " +
"font-family: Arial, Helvetica, sans-serif; " +
"font-weight: bold; " +
"font-size: 18px; " +
"color: #3333CC; " +
"} " +
".style3 { " +
"font-family: 'Times New Roman', Times, serif; " +
"color: #003399; " +
"} " +
".style4 { " +
"font-family: Arial, Helvetica, sans-serif; " +
"font-weight: bold; " +
"font-size: 12px; " +
"} " +
".style11 { " +
"color: #1A588D; " +
"font-family: 'Times New Roman', Times, serif; " +
"font-weight: bold; " +
"} " +
".style15 { " +
"color: #1A588D; " +
"font-weight: bold; " +
"} " +
".style18 {color: #FFFFFF; font-weight: bold; } " +
"body { " +
"margin-top: 1px; " +
"margin-left: 1px; " +
"margin-right: 1px; " +
"margin-bottom: 1px; " +
"} " +
"</style> " +
"<link href='Untitled-1.htm' id='1' title='view'> " +
"<script language='JavaScript' type='text/JavaScript'> " +
"function MM_reloadPage(init) { " +
"if (init==true) with (navigator) {if ((appName=='Netscape')&&(parseInt(appVersion)==4)) { " +
"document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }} " +
"else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload(); " +
"} " +
"MM_reloadPage(true); " +
"</script> " +
"<style type='text/css'> " +
"a:link { " +
"text-decoration: none; " +
"} " +
"a:visited { " +
"text-decoration: none; " +
"} " +
"a:hover { " +
"text-decoration: none; " +
"} " +
"a:active { " +
"text-decoration: none; " +
"} " +
".style20 {font-size: 12px} " +
"</style></head> " +
"<body> " +
"<p class='style1'><img src='cid:uniqueId' width='145' height='111'></p> " +
"<table border= 1 align ='left'>" +
"<tr>" + "<td>Employee ID :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["EmpID"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Employee Name :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["FIRSTNAME"].ToString() + " " + ds.Tables[0].Rows[i]["LASTNAME"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Department :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["DeptName"].ToString() + "</td>" +
"</tr>" +
"<tr>" + "<td>Message :" + "</td>" +
"<td>" + ds.Tables[0].Rows[i]["emessage"].ToString() + "</td>" +
"</tr>" +
"<tr>"+
"<td>"+
"<pre align='left' class='style3'><strong><img src='cid:uniqueId1' width='286' height='177'></strong></pre> " +
"<pre align='left' class='style4'> <a name='t'></a> Please do not reply to this email.</pre>" +
"<p align='left' class='style3'> </p> " +
"</td>"+"</tr>"+"</table>"+
"</body> " +
"</html> ";
if (flage == "N" && mg2 == "Wish You a Very Happy Returns of the Day.<P> From - Daccess Security Systems Pvt ")
{
SendMail12(account, passwo, t, sub, mg, ecc, servername1, portnum);
sql = "Update EmailSender set eflag ='Y' where SerNo = '" + sn.ToString() + "'";
SqlCommand cmd4 = new SqlCommand(sql, con.GetConnection());
cmd4.ExecuteNonQuery();
}
}
}
else
{
servername1 = "";
portnum = 0;
account = "";
passwo = "";
MessageBox.Show("Email Setting Is Not Stored");
}
}
}
// Send mail function
public static bool SendMail12(string gMailAccount, string password, string to, string subject, string message, string cc, string server, int port)
{
try
{
NetworkCredential loginInfo = new NetworkCredential(gMailAccount, password);
MailMessage msg = new MailMessage();
msg.From = new MailAddress(gMailAccount);
msg.To.Add(new MailAddress(to));
string[] s;
s = cc.Split(';');
for (int i = 0; i < s.Length; i++)
{
msg.CC.Add(new MailAddress(s[i].ToString()));
}
msg.Subject = subject;
msg.Body = message;
msg.IsBodyHtml = true;
SmtpClient client = new SmtpClient();
client.Host = server;
client.Port = port;
client.Timeout = 100000;
client.EnableSsl = true;
client.UseDefaultCredentials = true;
client.Credentials = loginInfo;
string palinBody = "Plain text content, viewable by those clients that don't support html";
AlternateView plainView = AlternateView.CreateAlternateViewFromString(palinBody, null, "text/plain");
string htmlBody = message;
AlternateView htmlView = AlternateView.CreateAlternateViewFromString(htmlBody, null, "text/html");
//create the AlternateView for embedded image
AlternateView imageView = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\Daccess-logo.gif", MediaTypeNames.Image.Gif);
imageView.ContentId = "uniqueId";
imageView.TransferEncoding = TransferEncoding.Base64;
AlternateView imageView1 = new AlternateView("D:\\Aniket Work\\New Folder Update\\EmailSender\\EmailSender\\images\\birthday1images.jpg", MediaTypeNames.Image.Jpeg);
imageView1.ContentId = "uniqueId1";
imageView1.TransferEncoding = TransferEncoding.Base64;
//add the views
msg.AlternateViews.Add(plainView);
msg.AlternateViews.Add(htmlView);
msg.AlternateViews.Add(imageView);
msg.AlternateViews.Add(imageView1);
client.Send(msg);
return true;
}
catch (Exception e)
{
return false;
}
}
You should be giving absolute paths to your resources
e.g.
in above code, your body background should be something like
<body background= 'http://yourdomain.com/meet.jpg'>
same thing applies to your image tag or you can have inline content disposition
EDIT
Do you see something like this when you view the mail?

Resources