Good morning everyone,
I have a system which needs send a e-mail with some variables that I have in my JS. The code, at begin, looks fine to me, but the Request.QueryString returns me nothing. I am trying to receive data from the URL with Request.Url.ToString() and that show me all the url sended by the JS, which means the JS is sending, but the Request.QueryString can´t read the values.
Can someone please help me with this?
Below I show the code.
<script type="text/javascript">
var nomeCarinha;
$(document).on("click", "[id*=lnkView]", function () {
$("#nome").html($(this).closest("tr").find("td.sDisplayName").text());
$("#Product").html($(this).closest("tr").find(".Produto").text());
$("#IP").html($(this).closest("tr").find("td.sNetworkAddress").text());
$("#DC").html($(this).closest("tr").find("td.dc").text());
$("#comentario").html($(this).closest("tr").find("td.sComment").text());
$("#inicio").html($(this).closest("tr").find("td.inicio").text());
$("#mensagem").html($(this).closest("tr").find(".mensagem").text());
$("#monitor").html($(this).closest("tr").find("td.sMonitorTypeName").text());
$("#dialog").dialog({
width: 1000,
title: "Detalhes para TP",
buttons: {
Email: function (nome) {
var width = 150;
var height = 250;
var left = 99;
var top = 99;
var nome = $(this).find("#nome").text();
var produto = $(this).find("#product").text();
var ip = $(this).find("#IP").text();
var dc = $(this).find("#DC").text();
var comentario = $(this).find("#comentario").text();
var inicio = $(this).find("#inicio").text();
var mensagem = $(this).find("#mensagem").text();
var monitor = $(this).find("#monitor").text();
var janeleira = window.open("outlookPrimeiro.aspx?nomeDevice="+nome+"&nomeIp"+ip+"&nomeDc="+dc+"&nomeComentario="+comentario+"&nomeInicio="+inicio+"&nomeMonitor="+monitor, 'janela', 'width=' + width + ', height=' + height + ', top=' + top + ', left=' + left + ', scrollbars=yes, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no, setTimeout=1000');
// Rescrever no outlookprimeiro.aspx para tirar os + no lugar de espaço da URL
},
Ok: function () {
$(this).dialog('close');
}
},
modal: true
});
return false;
});
function blinker() {
$('.blink').fadeOut(500);
$('.blink').fadeIn(500);
}
setInterval(blinker, 1000); //Runs every second
And the receive:
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//NECESSÁRIO PARA USAR MARSHALL
using System.Runtime.InteropServices;
//NECESSARIO PARA USAR O OUTLOOK
using aqueleLance = Microsoft.Office.Interop.Outlook;
using OutlookApp = Microsoft.Office.Interop.Outlook.Application;
using testeUsingPrimeiro = Microsoft.Office.Interop.Outlook._AutoFormatRule;
using testeUsingSegundo = Microsoft.Office.Interop.Outlook._AutoFormatRules;
using testeUsingTerceiro = Microsoft.Office.Interop.Outlook.AutoFormatRule;
using testeUsingQuarto = Microsoft.Office.Interop.Outlook.AutoFormatRules;
public partial class outlookPrimeiro : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String nomeDevice = Request.Url.ToString();
//String nomeProduto = "TESTE";
String nomeIp = Request.QueryString["ip"];
String nomeDc = Request.QueryString["dc"];
String nomeComentario = Request.QueryString["comentario"];
String nomeInicio = Request.QueryString["inicio"];
String nomeMonitor = Request.QueryString["monitor"];
//DEFINICICOES DE DADOS DO E-MAIL A SER ENVIADO
String paraEmail = "noc#email.com.br";
String copiaEmail = "mateus#email.com.br";
//String copiaOculta = "";
String assuntoEmail = "Usando Outlook 2013
String corpo = "<html><body><div style='width:95%;text-align: center;background-color: black'><table style='width: 100%;text-align: center'><tr style='background-color:#5B2E90'><td style='color: white'>Prioridade</td><td style='color: white'>Acionamento</td><td style='color: white'>KBN</td><td style='color: white'>Device</td><td style='color: white'>IP</td><td style='color: white'>DC</td><td style='color: white'>WUG</td><td style='color: white'>Diretorio</td><td style='color: white'>Monitor</td><td style='color: white'>Comentario</td><td style='color: white'>Tempo Down</td><td style='color: white'>Inicio</td><td style='color: white'>TP</td></tr><tr><td style='color: orange'>Prioridade</td><td style='color: orange'>Acionamento</td><td style='color: orange'>KBN</td><td style='color: orange'>" + nomeDevice + "</td><td style='color: orange'>" + nomeIp + "</td><td style='color: orange'>" + nomeDc + "</td><td style='color: orange'>WUG</td><td style='color: orange'>Diretorio</td><td style='color: orange'>" + nomeMonitor + "</td><td style='color: orange'>COMENTARIO</td><td style='color: orange'>Tempo Down</td><td style='color: orange'>" + nomeInicio + "</td><td style='color: orange'>TP</td></tr></table></div></body></html>";
//CRIA NOVO APP USANDO Microsoft.Office.Interop.Outlook.Application
OutlookApp appDoOutlook = new OutlookApp();
//CRIA E-MAIL
aqueleLance.MailItem itemDoMail = appDoOutlook.CreateItem(aqueleLance.OlItemType.olMailItem) as aqueleLance.MailItem;
//QUAL CONTA VAI ENVIAR? NECESSÁRIO TER A CONTA NA MÁQUINA
string nomeDaConta = "noc#linx.com.br";
//CRIA SESSÃO
aqueleLance.NameSpace sessao = itemDoMail.Session;
//PEGA CONTAS PRESENTES NA MÁQUINA
aqueleLance.Accounts contaAccounts = sessao.Accounts;
//FOR 1 ATÉ FINAL DO NÚMERO DE CONTAS
for (int i = 1; i <= contaAccounts.Count; i++)
{
//aqueleLance.Account contaAccount RECEBE O VALOR DO FOR
aqueleLance.Account contaAccount = contaAccounts[i];
//SE A CONTA EXISTE, ELE VAI ENVIAR
//(COMPARAÇÃO FEITA EM LOWER CASE
if (contaAccount.DisplayName.ToLower() == nomeDaConta.ToLower())
{
//COMANDO PARA ENVIAR USANDO A CONTA XXXXX
itemDoMail.SendUsingAccount = contaAccount;
//LIBERA VARIAVEL
Marshal.ReleaseComObject(contaAccount);
//PARA O COMANDO
break;
}
}
//PARA QUEM ENVIA O E-MAIL
itemDoMail.To = paraEmail;
//ENVIAR COM COPIA PARA
itemDoMail.CC = copiaEmail;
//COPIA OCULTA
//itemDoMail.BCC = copiaOculta;
//ASSUNTO DO EMAIL
itemDoMail.Subject = assuntoEmail;
//CORPO DO EMAIL EM HTML
itemDoMail.HTMLBody = corpo;
//"<html><body>Enviado pelo <strong>Outlook</strong> 2013<br/> Teste do envio com CC e BCC.<br/><br/></body></html>"
//IMPORTANCIA DO EMAIL
itemDoMail.Importance = aqueleLance.OlImportance.olImportanceHigh;
//ENVIA O EMAIL
//NÃO É POSSÍVEL VER ANTES DE ENVIAR SEM HABILITAR O DISPLAY ABAIXO
//itemDoMail.Send();
//HABILITE ISSO PARA VER A MENSAGEM ANTES DE ENVIAR
//PRECISA TIRAR O SEND ACIMA
itemDoMail.Display(false);
//LIBERA CONTAS
Marshal.ReleaseComObject(contaAccounts);
//LIBERA SESSÃO
Marshal.ReleaseComObject(sessao);
}
}
You're not using the same keys for your values:
"nomeDevice="+nome+"&nomeIp="+ip+"&nomeDc="+dc+"&nomeComentario="+comentario+"&nomeInicio="+inicio+"&nomeMonitor="+monitor
So you should also read these in the C# code:
String nomeIp = Request.QueryString["nomeIp"];
String nomeDc = Request.QueryString["nomeDc"];
String nomeComentario = Request.QueryString["nomeComentario"];
String nomeInicio = Request.QueryString["nomeInicio"];
String nomeMonitor = Request.QueryString["nomeMonitor"];
Also note that you should absolutely escape the content on the JavaScript side using encodeURIComponent(), otherwise your users can make the request fail by having for instance a & in the comentario... e.g.:
"outlookPrimeiro.aspx"+
"?nomeDevice="+encodeURIComponent(nome)+
"&nomeIp="+encodeURIComponent(ip)+
"&nomeDc="+encodeURIComponent(dc)+
"&nomeComentario="+encodeURIComponent(comentario)+
"&nomeInicio="+encodeURIComponent(inicio)+
"&nomeMonitor="+encodeURIComponent(monitor)
Try To change:
String nomeIp = Request.QueryString["ip"];
To
String nomeIp = Request.QueryString["nomeIp"]
and so on...
also, there's small typo. +"&nomeIp"+ip+ should be +"&nomeIp="+ip+
Related
How can I change the size of the bindPopup since when opening the web from a mobile phone it is very large, in the image that shows a lot of space is left below, is there any way to reduce that size?
search the internet but there are no results almost everything is from the bookmarks
This is part of the code I use to display this information:
const updateMap = () => {
const Buslocation =
"https:xxxxxxxxxxxxx" + gtebi;
fetch(Buslocation)
.then((res) => res.json())
.then((data) => {
//si existe el marcador removerlo para no tener marcadores duplicados
if (bus_marker) {
map.removeLayer(bus_marker);
}
//asignar valores que se usaran ingresar el marcador
const latitud = data.latitud;
const longitud = data.longitud;
//asignar valores que se usaran mas adelate para definir el popup
const destino = data.destino;
const origen = data.origen;
const patente = data.patente;
//animacion para dirigirse al punto donde se encuentra el bus
map.flyTo([latitud, longitud], 12);
//crear marcador
bus_marker = L.marker([latitud, longitud], {
icon: busicon,
})
.addTo(map)
.bindPopup(
"<strong><h3>El bus esta aquí</h3></strong>" +
"<h5>Origen: " +
"<strong>" +
origen +
"</strong>" +
"</h5>" +
"<h5>Destino: " +
"<strong>" +
destino +
"</strong>" +
"</h5>" +
"<h5>Patente: " +
"<strong>" +
patente +
"</strong>" +
"</h5>"
)
.update();
});
//definir el tiempo de actualizacion del marcador(bus)
setTimeout(updateMap, 180000);
};
I searched the internet but I only get options for the map markers.
or if I can remove the bindPopup somehow, because if I don't use it, the white bar is left next to it.
I am working with MVC and I am creating a dynamic table as data from # Html.TextBoxFor is added that I have in my view, and all good so far
My question is: Any way to save my table that I create with a JS function?
Searching the web I found some examples but so far nothing works for me
My Table
<table id="mytable" class="table table-bordered table-hover ">
<tr bgcolor="#90A8D0">
<th>Proyecto</th>
<th>Cuenta</th>
<th>Sub Cuenta</th>
<th>Beneficiario</th>
<th>Tipo de Pago</th>
<th>Pago en el proyecto</th>
<th>Pago Por México</th>
<th>Tarjeta Usuario</th>
<th>Total de Remesa</th>
<th>Obersvaciones</th>
<th>Eliminar</th>
</tr>
</table>
So I create my dynamic table:
$(document).ready(function() {
$('#adicionar').click(function () {
debugger;
var Proyecto = $("#ProyectoID option:selected").text();
var Recurso = $("#RecursoID option:selected").text();
var SubRecurso = $("#SubRecursoID option:selected").text();
var Beneficiario = document.getElementById("Beneficiario").value;
var TipoPago = $("#TipoPagoID option:selected").text();
var PagoProyecto = document.getElementById("PagoProyecto").value;
var PagoMexico = document.getElementById("PagoMexico").value;
var TarjetaUsuario = document.getElementById("TarjetaUsuario").value;
var TotalRemesa = parseInt(PagoProyecto) + parseInt(PagoMexico) + parseInt(TarjetaUsuario);
var ObervacionesCuenta = document.getElementById("ObervacionesCuenta").value;
var i = 1; //contador para asignar id al boton que borrara la fila
var fila = '<tr id="row' + i + '"><td>' + Proyecto + '</td><td>' + Recurso + '</td><td>' + SubRecurso + '</td><td>' + Beneficiario + '</td><td>' + TipoPago + '</td><td>' + PagoProyecto + '</td><td>' + PagoMexico + '</td><td>' + TarjetaUsuario + '</td><td>' + TotalRemesa + '</td><td>' + ObervacionesCuenta + '</td><td><button type="button" name="remove" id="' + i + '" class="btn btn-danger btn_remove">Quitar</button></td></tr>'; //esto seria lo que contendria la fila
i++;
$('#mytable tr:first').after(fila);
$("#adicionados").text(""); //esta instruccion limpia el div adicioandos para que no se vayan acumulando
var nFilas = $("#mytable tr").length;
$("#adicionados").append(nFilas - 1);
//le resto 1 para no contar la fila del header
document.getElementById("Recurso").value ="";
document.getElementById("SubRecurso").value = "";
document.getElementById("Proyecto").value = "";
document.getElementById("Proyecto").focus();
});
$(document).on('click', '.btn_remove', function () {
var button_id = $(this).attr("id");
//cuando da click obtenemos el id del boton
$('#row' + button_id + '').remove(); //borra la fila
//limpia el para que vuelva a contar las filas de la tabla
$("#adicionados").text("");
var nFilas = $("#mytable tr").length;
$("#adicionados").append(nFilas - 1);
});
});
This is an example I found on the web:
$(function () {
debugger;
$('#mytable').each(function () {
var cuotaNo= $(this).find('td').eq(0).html();
var interes = $(this).find('td').eq(1).html();
var abonoCapital = $(this).find('td').eq(2).html();
var valorCuota = $(this).find('td').eq(3).html();
var saldoCapital = $(this).find('td').eq(4).html();
$.ajax({
async: false,
type: "POST",
url: "../Guardardatos",
data:"cuotaNo="+cuotaNo+"&interes="+interes+"&abonoCapital="+abonoCapital+"&valorCuota="+valorCuota+"&saldoCapital="+saldoCapital,
data: {valores:valores},
success: function(data) { if(data!="");}
});
});
});
As this last example is what I am trying to save the data that is created in my table
In this example, create TableView, TableRowView, and TableCellView classes. Each class returns an object with an element property and render* method. TableView.element uses the table provided in your example. TableRowView.element and TableCellView.element both create new elements.
After the data from the form (not shown in your example) is POSTED and the success callback is executed: first, create a new instance of TableView; second, create a new instance of TableRowView; third, create new instances of TableCellView for each data property, then render the property value inside of it.
To ensure that the correct order of data elements is rendered, use columnOrder to define the table cell names, the iterate over them in the onSuccess callback. Each iteration, use the column name to access the corresponding data property.
const columnOrder = [
'proyecto',
'cuenta',
'subCuenta',
'beneficiario',
'tipoPago',
'pagoProyecto',
'pagoMexico',
'tarjetaUsuario',
'totalRemesa',
'obersvaciones',
'elminar',
]
const TableView = () => {
let table = document.getElementByID('myTable')
return {
element: table,
renderTableRow: (element) => {
this.element.appendChild(element)
return this
}
}
}
const TableRowView = () => {
let tr = document.createElement('tr')
return {
element: tr,
renderTableCell: (element) => {
this.element.appendChild(element)
return this
},
}
}
const TableCellView = () => {
let td = document.createElement('tr')
return {
element: td,
render: (value) => {
this.element.innerHTML = value
return this
},
}
}
const onSuccess = (event) => {
let data = event.data
/*
data
-----
{
'proyecto': ??,
'cuenta': ??,
'subCuenta': ??,
'beneficiario': ??,
'tipoPago': ??,
'pagoProyecto': ??,
'pagoMexico': ??,
'tarjetaUsuario': ??,
'totalRemesa': ??,
'obersvaciones': ??,
'elminar': ??,
}
*/
let table = new TableView()
let row = new TableRow()
columnOrder.forEach((columnName) => {
let cell = new TableCellView()
let cellData = data[columnName]
cell.render(cellData)
row.renderTableCell(cell.element)
table.renderTableRow(row.element)
})
}
$.ajax({
...,
success: onSuccess,
})
I want to open a new url, pasing parameters using jquery, this is the way that im doing it,
$('#BtnPrintFlujo').click(function(e) {
var url = '#Url.Action("BillingxCashier", "Reports",new {area="Configurations" })';
url += "/opParam=" + $("#Users option:selected").val() +
"&fromDate=" + $('#FromDate').val() +
"&toDate=" + $('#ToDate').val();
var win = window.open(url);
if (win) {
win.focus();
} else {
alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
}
});
but, it said this error
Request.Path dangerous on the client (&).
$('#BtnPrintFlujo').click(function(e) {
var url = '#Url.Action("BillingxCashier", "Reports",new {area="Configurations" })';
url += "?opParam=" + $("#Users option:selected").val() +
"&fromDate=" + $('#FromDate').val() +
"&toDate=" + $('#ToDate').val();
var win = window.open(url);
if (win) {
win.focus();
} else {
alert("Porfavor, debes permitir que se abran las ventanas emergentes o el reporte no va a salir :'( ");
}
});
you missed an question mark before first parameter,
url += "?opParam=" + $("#Users option:selected").val() +
try this
I have a function inside of an immediately invoked function expression and I want to be able to access that function globally without lexically scoping it that way.
How can I access this "private" function through a namespace called "App"?
indew.html:
<html>
<head>
<meta charset="utf-8">
<title>Test</title>
<script src="filtering.js"></script>
</head>
<body>
<article>
<p>
Computer graphics is widespread today. Computer imagery is found on televi
surfaces, illumination sources, and so forth, perhaps with a dynamic (time) component".[3]
</p>
</article>
<section id="result"></section>
<script>
App.showOccurenceFiltering(); // here is my wrong call
</script>
</body>
</html>
js script :
var App = (function () {
function showOccurenceFiltering() {
"use strict";
var filteredWordsArray = filtering(),
resultView = "<ol>";
for (var i = 0; i < filteredWordsArray.length; i++) {
var partWord = filteredWordsArray[i].substring(0, filteredWordsArray[i].indexOf(" ")), // de 0 jusqua l espace : la partie mot
partNumber = filteredWordsArray[i].substring(filteredWordsArray[i].indexOf(" ") + 1); // de l'espace à la fin : la partie number
resultView += "<li>" + partWord + " (" + partNumber + ")</li>";
}
resultView += "</ol>";
document.getElementById('result').innerHTML = resultView;
}
}(App));
so i got an error of a miss call like shows the capture :
how should i resolve my problem ??
You'll need to expose the function to the global scope. You can do this with a namespace, like this:
(function () {
function showOccurenceFiltering() {
"use strict";
var filteredWordsArray = filtering(),
resultView = "<ol>";
for (var i = 0; i < filteredWordsArray.length; i++) {
var partWord = filteredWordsArray[i].substring(0, filteredWordsArray[i].indexOf(" ")), // de 0 jusqua l espace : la partie mot
partNumber = filteredWordsArray[i].substring(filteredWordsArray[i].indexOf(" ") + 1); // de l'espace à la fin : la partie number
resultView += "<li>" + partWord + " (" + partNumber + ")</li>";
}
resultView += "</ol>";
document.getElementById('result').innerHTML = resultView;
}
// Prepare a "dummy" object
var obj = {};
// Attach the private function to this object
obj.showOccurenceFiltering = showOccurenceFiltering;
// Attach the dummy object to the global scope in a controlled namespace:
window.App = obj;
}());
Then you can access the function like this:
App.showOccurenceFiltering();
You could do the following:
var App = (function(){
var obj = {};
obj.showOccurenceFiltering = function() {
"use strict";
var filteredWordsArray = filtering(),
resultView = "<ol>";
for (var i = 0; i < filteredWordsArray.length; i++) {
var partWord = filteredWordsArray[i].substring(0, filteredWordsArray[i].indexOf(" ")), // de 0 jusqua l espace : la partie mot
partNumber = filteredWordsArray[i].substring(filteredWordsArray[i].indexOf(" ") + 1); // de l'espace à la fin : la partie number
resultView += "<li>" + partWord + " (" + partNumber + ")</li>";
}
resultView += "</ol>";
document.getElementById('result').innerHTML = resultView;
}
return obj;
}());
Your App variable remains undefined because the Immediately Invoked Function Expression does not return a value.
Instead, define App as an object literal, as follows:
var App = {
showOccurenceFiltering: function() {
"use strict";
var filteredWordsArray = filtering(),
resultView = "<ol>";
for (var i = 0; i < filteredWordsArray.length; i++) {
var partWord = filteredWordsArray[i].substring(0, filteredWordsArray[i].indexOf(" ")), // de 0 jusqua l espace : la partie mot
partNumber = filteredWordsArray[i].substring(filteredWordsArray[i].indexOf(" ") + 1); // de l'espace à la fin : la partie number
resultView += "<li>" + partWord + " (" + partNumber + ")</li>";
}
resultView += "</ol>";
document.getElementById('result').innerHTML = resultView;
}
};
Now your call will be valid.
I'm trying to send mail to a list of people with some important data that i need to be in the e-mail formatted as bold. I tried to use the string.setBold() but it says that the function does not exist. By the way the email is something like this:
var emailBody = "¡Hola " + name + "!" +
"\n\nTe informamos que tienen un pago pendiente por " +
acobrar + " con el equipo " + equipo + " en Liga Siete" +
". Segun nuestros registros han realizado los siguientes pagos" +
pagos + "\n\nTe recordamos que con la tarifa " + tarifa +
" deben cancelar un total de " + apagar +
" y que la garantía no se considera como abono. Recuerda que esta cuota debe ser pagada antes del " +
deadline +
" o quedaran inhabilitados de jugar o incluso perder el cupo."
Where the variable name, equipo, tarifa and apagar must be in bold.
How can I accomplish this?