我在页面中动态创建了我的复选框.我想为动态创建的所有复选框添加click事件.
这是我的代码.
<div data-role="fieldcontain">
<fieldset data-role="controlgroup" id="br">
</fieldset>
</div>
Run Code Online (Sandbox Code Playgroud)
我动态创建了复选框并附加到fieldset.
$.getJSON("http://localhost/WebSite/",
function(data){
var branchOp="";
$.each(data.branch, function(i,item){
branchOp += '<input type="checkbox" name="branch" id="'+item.branchCode+'" value="'+item.branchCode+'" class="branch"><label for="'+item.branchCode+'">'+item.branchName+'</label>';
$(item.branchCode).addClass("intro");
});
$('#br').append(branchOp).trigger( "create" );
});
Run Code Online (Sandbox Code Playgroud)
我使用on(),live(),deligate()方法在复选框上添加事件处理程序.
$('#br').delegate('click','input:checkbox', function(event) {
alert('selected');
});
$('#br').on('click','input:checkbox', function(event) {
alert('selected');
});
Run Code Online (Sandbox Code Playgroud)
没有什么对我有用......
我正在开发一个项目,我在其中有一个表单,通过该表单我可以在列表视图中编辑可用的问题.每当我从列表视图中选择一行并单击"修改"按钮时,列表视图上方的文本框会加载问题及其选项.这意味着当我在列表视图中选择一行并单击"修改"按钮时,问题会将其自身加载到文本框中.我在那里编辑问题并单击"保存"以保存更改,但我无法访问文本框中的数据.它说{"Input string was not in a correct format."}.
我的表单frmFormWizard's'编辑'按钮的代码如下:
frmFormWizard.cs代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.Sql;
using System.Data.SqlClient;
namespace SurveyBuilder
{
public partial class frmFormWizard : Form
{
int intPanelNumber = 1;
Boolean blnCancel = false;
//int intFlag = 1;
public frmFormWizard()
{
InitializeComponent();
}
...
private void btnEditTwoOrMoreOptions_Click(object sender, EventArgs e)
{
int QuestionID;
string sql;
QuestionID = Convert.ToInt32(lvTwoOrMoreOptions.SelectedItems[0].Text.ToString());
{
SqlConnection cn = …Run Code Online (Sandbox Code Playgroud) 我正在使用nodemailer模块在我的 Sails.js 项目中发送电子邮件。现在我想知道是否有一种方法可以知道电子邮件是否已成功发送,或者电子邮件是否因某些附件而失败或可能是错误的电子邮件地址。
我如何确保电子邮件地址有效?或者电子邮件是否成功发送到相关电子邮件地址?
我已经阅读了 nodemailer 文档并对其进行了一些研发,但到目前为止我找不到任何有成效的东西。
请让我知道是否有办法确认电子邮件。
谢谢。
我第一次在三层架构上工作,我在一个解决方案中创建了三个项目,一个名为BLL,第二个名为DAL,第三个名称为Model,我在模型中创建了接口,现在要创建BLL中的业务逻辑,并希望将其连接到我已连接数据库的DAL.
为了这个目的,我添加了每个项目的参考,其他像我在模型中添加了BLL的参考,并在DAL中添加了BLL的参考.
现在,我已经创建了一个类是DAL,其中我连接了我的数据库并且已经在模型中创建了一个Windows窗体,
我连接数据库的类是
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient();
namespace WindowsFormsApplication3
{
class DB
{
public void fnc_ConnectoToDB(ref SqlConnection cn)
{
string strConnectionString = null;
strConnectionString = @"Data Source=AHSANMUGHAL;Initial Catalog=SurveyBuilder;User ID=sa;Password=ahsan";
cn = new SqlConnection();
cn.ConnectionString = strConnectionString;
cn.Open();
}
public void fnc_CloseCn(ref SqlConnection cn)
{
if (cn.State == ConnectionState.Open == true)
{
cn.Close();
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我知道这是一个有点令人困惑的问题,但我希望你们能理解它并尽快解决
我正在使用PayPal Express Checkout而且我需要做的是单独授权和捕获付款,我目前的PayPal流程是,
1)我使用以下代码创建付款:
var paypal = require('paypal-rest-sdk');
function createPayPal(req, res, itemsArray, redirectsTos) {
var payment = {
"intent": "sale",
"payer": {},
"transactions": [{
"amount": {
"currency": sails.config.currency,
"total": itemsArray.totalArrayAmount,
"details": {
"subtotal": itemsArray.totalArrayAmount,
"fee": sails.config.PayPalCreateFee
}
},
"invoice_number": req.session.invNum,
"item_list": {
"items": itemsArray.itemsArray
}
}]
};
sails.log.info('payment obj :', JSON.stringify(payment))
payment.payer.payment_method = sails.config.PayPalPaymentMethod;
payment.redirect_urls = {
"return_url": res.locals.return_url_buy,
"cancel_url": res.locals.cancel_url_buy
};
paypal.payment.create(payment, function(error, payment) {
if (error) {
sails.log.error(error);
redirectsTos(({
message: 'failure',
redirect: '/paypal/error'
}), null);
} else { …Run Code Online (Sandbox Code Playgroud) 我正在处理库存软件,并且还按百分比和金额计算折扣.
我用来转换价格%的代码是这样的:
if(txtDiscount.Text == "" || txtGrandTotal.Text == "")
{
MessageBox.Show("Please Enter amount in Grand Total",Application.ProductName,MessageBoxButtons.OK,MessageBoxIcon.Information);
}
else
{
// double percent;
double grandTotal;
double per;
double txDiscount;
//percent = Convert.ToInt32(txtPercant.Text);
grandTotal = Convert.ToInt32(txtGrandTotal.Text);
txDiscount = Convert.ToInt32(txtDiscount.Text);
per = txDiscount / grandTotal * 100;
//per = percent / 100 * grandTotal;
if (per % 3 != 0)
per = (per - per % 3) + 3;
txtPercant.Text = Convert.ToString(per);
................
................
................
................
................
Run Code Online (Sandbox Code Playgroud)
现在让我们假设如果我输入的金额是"25",那么它计算的百分比是"2.77777777777778".我想把它限制在点之后的三位小数,就像我想成为"2.778"或者我想在点之后只显示3位小数的任何意思,任何人都可以帮助我以哪种方式做到这一点?任何建议,将不胜感激!!
从价格到%代码的转换是:
private …Run Code Online (Sandbox Code Playgroud) 嗨,我正在读一本名为"Beginning Visual C#2012 Programming"的书,这本书在第4章的lopping部分中给出了以下的例子.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ChapterFourExcerciseFour
{
class Program
{
static void Main(string[] args)
{
double balance, interestRate, targetBalance;
int totalYears = 0;
//reading balance from the console and saving it into the balance
Console.WriteLine("Please Enter your balance");
balance = Convert.ToDouble(Console.ReadLine());
//reading interesrrate from the console and saving it into tht interesrrate
Console.WriteLine("What is your current interest rate");
interestRate = Convert.ToDouble(Console.ReadLine());
//reading targetbalance from the console and saving …Run Code Online (Sandbox Code Playgroud) 我是C#的新手,现在正在研究控制台应用程序,我编写了以下代码:
Program.cs中
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ch06Ex01
{
class Program
{
static void Write()
{
Console.WriteLine("Please enter any string..!!");
}
static void Main(string[] args)
{
Write();
string name = Console.ReadLine();
Write();
string name1 = Console.ReadLine();
Write();
string name2 = Console.ReadLine();
Write();
string name3 = Console.ReadLine();
Console.WriteLine("{0}, {1}, {2}, {3}",name,name1,name2,name3);
Console.WriteLine("enter \"y\" to restart the program and \"n\" to exit the Program");
string selectedOption = Console.ReadLine();
if (selectedOption == "y")
{
// howto call …Run Code Online (Sandbox Code Playgroud) 我正在开发一个项目,我正在创建一个实例并在我的程序中打开一个特定的表单,就像我使用下面的代码打开一个表单:
frm2 cs = new frm2();
cs.Show();
Run Code Online (Sandbox Code Playgroud)
但这里的问题是每次我点击按钮它只是打开一个新窗口,前一个也打开了,我想在这里做的是当我点击按钮,那个窗口已经打开然后它只是去了打开窗户,除了打开新窗户.希望你们理解我的问题,并帮助我做到这一点.
我试过这段代码:我在frm2.cs文件中写的代码是:
public partial class frm2 : Form
{
private static frm2 _form2 = null;
public frm2()
{
InitializeComponent();
}
public static frm2 Instance
{
get
{
if (_form2 == null)
{
_form2 = new frm2();
}
return _form2;
}
}
Run Code Online (Sandbox Code Playgroud)
并在frmMain.cs文件中我编码访问实例并打开项目是:
private void addProductToolStripMenuItem_Click(object sender, EventArgs e)
{
frm2.Instance.Show();
//frm2 cs = new frm2();
//cs.Show();
}
Run Code Online (Sandbox Code Playgroud)
它第一次工作正常,但当我打开frm2,关闭它然后再次尝试打开它编译器给出错误, frm2.Instance.Show(); 错误来了是
: Cannot access a disposed object.
Object name: 'frm2'.
Run Code Online (Sandbox Code Playgroud) .net ×6
c# ×6
winforms ×3
sails.js ×2
console ×1
email-client ×1
javascript ×1
jquery ×1
node.js ×1
nodemailer ×1
paypal ×1
types ×1