- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我基于 ASP.NET 网络的应用程序中,我有一个普通的 ASP.NET 按钮,它背后有一个发送电子邮件的方法,如下所示:
ASP.NET 代码:
<asp:Button ID="btnSendReminders" runat="server" Text="Send Reminders" OnClick="btnSendReminders_Click" />
代码隐藏:
protected void btnSendReminders_Click(object sender, EventArgs e)
{
SendEmailTOAllUser();
}
protected void SendEmail(string toAddresses, string fromAddress, string MailSubject, string MessageBody, bool isBodyHtml)
{
SmtpClient sc = new SmtpClient("Mail Server");
try
{
MailMessage msg = new MailMessage();
msg.From = new MailAddress("pssp@aramco.com", "PMOD Safety Services Portal (PSSP)");
// In case the mail system doesn't like no to recipients. This could be removed
//msg.To.Add("psTeesstp@DomainServer.com");
msg.Bcc.Add(toAddresses);
msg.Subject = MailSubject;
msg.Body = MessageBody;
msg.IsBodyHtml = isBodyHtml;
sc.Send(msg);
}
catch (Exception ex)
{
throw ex;
}
}
protected void SendEmailTOAllUser()
{
string connString = "Data Source=localhost\\sqlexpress;Initial Catalog=psspForTest;Integrated Security=True";
using (SqlConnection conn = new SqlConnection(connString))
{
var sbEmailAddresses = new System.Text.StringBuilder(2000);
string quizid = "";
// Open DB connection.
conn.Open();
string cmdText = "SELECT MAX (QuizID) As mQuizID FROM dbo.QUIZ WHERE IsSent <> 0";
using (SqlCommand cmd = new SqlCommand(cmdText, conn))
{
SqlDataReader reader = cmd.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
// There is only 1 column, so just retrieve it using the ordinal position
quizid = reader["mQuizID"].ToString();
}
}
reader.Close();
}
string cmdText2 = @"SELECT e.Username, d.DivisionShortcut
FROM
employee e
join Divisions d on (e.DivisionCode = d.SapCode)
left join
(select A.QuizID, a.Username
from UserQuiz a join
(select max(QuizID) QuizID from dbo.Quiz where IsSent=1) b
on a.QuizId = b.QuizID
) c
on e.Username = c.Username
WHERE c.QuizID is null
Order By d.DivisionShortcut";
using (SqlCommand cmd = new SqlCommand(cmdText2, conn))
{
SqlDataReader reader = cmd.ExecuteReader();
if (reader != null)
{
while (reader.Read())
{
var sName = reader.GetString(0);
if (!string.IsNullOrEmpty(sName))
{
if (sbEmailAddresses.Length != 0)
{
sbEmailAddresses.Append(",");
}
// Just use the ordinal position for the user name since there is only 1 column
sbEmailAddresses.Append(sName).Append("@DomainServer.com");
}
}
}
reader.Close();
// Add the parameter to the command
var oParameter = cmd.Parameters.Add("@QuizID", SqlDbType.Int);
var sEMailAddresses = sbEmailAddresses.ToString();
string link = "<a href='http://StartQuiz.aspx?testid=" + quizid + "'> Click here to participate </a>";
string body = @"<font color='red' size='18pt'><b> ***REMINDER*** </b></font> <br /><br />
Good day, <br /><br />
<b>This is just a gentle reminder asking you to participate in the last new short safety quiz </b>"
+ link +
@"<br /><br />
Also, give yourself a chance to gain more safety culture by reading the PMOD Newsletter.
<br /><br /><br />
PLEASE <span class='highlight'>IGNORE</span> THIS MESSAGE IF YOU HAVE ALREADY PARTICIPATED IN THIS QUIZ.
<br /> <br /><br /> <br />
This email was generated using the <a href='http://pmv/pssp/Default.aspx'>Safety Portal (PSSP) </a>.
Please do not reply to this email.";
int sendCount = 0;
List<string> addressList = new List<string>(sEMailAddresses.Split(','));
StringBuilder addressesToSend = new StringBuilder();
for (int userIndex = 0; userIndex < addressList.Count; userIndex++)
{
sendCount++;
if (addressesToSend.Length > 0)
addressesToSend.Append(",");
addressesToSend.Append(addressList[userIndex]);
if (sendCount == 10 || userIndex == addressList.Count - 1)
{
SendEmail(addressesToSend.ToString(), "", "REMINDER: Notification of New Weekly Safety Quiz", body, true);
addressesToSend.Clear();
sendCount = 0;
}
}
// Update the parameter for the current quiz
oParameter.Value = quizid;
// And execute the command
cmd.ExecuteNonQuery();
}
conn.Close();
}
}
现在,不用 <asp:Button>
,我想使用:
<ajaxToolkit:ConfirmButtonExtender ID="btnSendReminders" runat="server" TargetControlID="btnSendReminders"
ConfirmText="Are you sure you want to click this?"
OnClientCancel="CancelClick" />
有一个确认信息。但是我不知道为什么会出现以下错误:**
Extender control 'btnSendReminders' cannot extend 'btnSendReminders'. Extender controls of type 'AjaxControlToolkit.ConfirmButtonExtender' cannot extend controls of type 'AjaxControlToolkit.ConfirmButtonExtender'.
我也不知道为什么。那么我如何使用它而不是 <asp:button>
?
更新:
我刚刚弄清楚如何使用它。我应该按如下方式使用它:
<asp:Button ID="btnSendReminders" runat="server" Text="Send Reminders" OnClick="btnSendReminders_Click" />
<ajaxToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="btnSendReminders"
ConfirmText="Are you sure you want to send reminders to these employees?"
OnClientCancel="CancelClick">
</ajaxToolkit:ConfirmButtonExtender>
但现在的问题是,当出现确认信息时,点击取消按钮,页面仍然会刷新并发送提醒。 如何防止点击“取消”按钮的情况?
最佳答案
使用以下代码确认按钮 ajax 扩展器获取确认框:
<asp:Button ID="btnSendReminders" runat="server" Text="Send Reminders" OnClick="btnSendReminders_Click" />
<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server"
TargetControlID="btnSendReminders"
ConfirmText="Are you sure you want to Send Reminders?"
/>
关于c# - 如何使用 AjaxToolKit 确认按钮扩展器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9599170/
基本上,我有以下内容: .AjaxComboBoxWindowsStyle { position: relative; } .AjaxComboBoxWindowsStyle .ajax__c
一个展开收合的ajaxToolkit:AccordionPane控件。Insus.NET在专案有用到它。 因为它可以节省显示空间。不过有点不足,就是用户刚开始使用,需要记得每个AccordionPa
ajaxToolkit:ModalPopupExtender可以让用户模拟新开一个窗口,以下演示,就是在模拟新开窗口作多项选项的功能。 演示例子中,是Repeater结合C
Ajax的CalenderExtender的日期选择,下面可看到效果: Insus.NET使用ajaxToolkit:CalendarExtender,来实现日期选择功能。TextBox可以让
首先看看效果: 该控件的效果就是在TextBox控件上添加“水印”效果,也就是当TextBox为空时,显示提示消息,一旦TextBox聚焦,样式就消失。 In
我正在尝试制作将处理不同日期的文本框。为此,我使用 ajaxtoolkit,以便当用户单击文本框时,弹出日历将出现在文本框下方。我已经设法做到了,但问题是它只显示一个月中的 18 天左右,我想显示一个
我知道如何隐藏标签: MyTabContainerID.Tabs[1].Visible = false; 行得通。我遇到的问题是更改由 radioButtonList selectedIndexCha
在我基于 ASP.NET 网络的应用程序中,我有一个普通的 ASP.NET 按钮,它背后有一个发送电子邮件的方法,如下所示: ASP.NET 代码: 代码隐藏: protected void btn
有人知道禁用 CollapsiblePanelExtender 的客户端方法吗? 我已经通过 behaviorId 获得了扩展器。 var extender = $find("behaviorId")
我正在使用 ajaxcontrols 并且所有控件都运行良好但是我没有找到任何名为 HtmlEditorExtender 的控件所以我只是在 .html 页面中复制了这个标签 这里工作正常,但
我正在尝试在我的项目中实现 autoCompleteExtender。目前我正在使用 OnClientItemSelected 属性在客户端调用 javascript。有没有一种方法(使用另一个属性或
我在 ModalPopupExtender 中嵌入了一个文本编辑器。它弹出,父页面被“涂黑”,弹出窗口按预期居中。问题是父页面上有许多控件绘制在 ModalPopup 之上。我已经用 z-index
我有以下前端代码: ... hey guys this is to
尝试使用最新的ajaxToolKit NET4时出现此错误。 我已经下载了它,并按照说明进行了提取,并在工具箱中选择了dll并加载了它。 我添加的代码是使用扩展程序日历的文本框的简单日历 我缺
如何在 ajaxToolkit CalendarExtender 中使用时禁用以前的日期 最佳答案 在 html 标记中使用 Ajax 工具包 Calendar Extender: " EndDat
我有一个下拉列表,我在其中使用了 ajaxToolkit:ListSearchExtender。当我在搜索模式中插入一些文本时,下拉列表显示列表的所有值。我只想在下拉列表中显示与搜索模式匹配的那些值。
事实: 此特定屏幕中的 ajaxToolkit AutoCompleteExtender 在 IE 和 Firefox 中运行良好 ajaxToolkit AutoCompleteExtender 在
我正在尝试根据在线提供的演示代码实现“ajaxToolkit:SlideShowExtender”属性,还尝试了 GitHub 中的代码,如以下答案之一所示。 我尝试过的事情: 我查看了我网站的 We
如何以编程方式选择 TabContainer 的选项卡?以及如何获得选定的选项卡? 最佳答案 您可以像...一样设置标签索引 tbcName.ActiveTabIndex = 3; 和类似的 tbcN
我在我的页面中使用 AjaxToolkit 组合框...我正在尝试更改组合按钮的宽度。但我做不到。因为它默认有内联样式.. 我尝试了下面的代码来添加样式 //组合CSS .ComboClass .a
我是一名优秀的程序员,十分优秀!