在asp.net中的popupcontrolextender中使用会话值 [英] Use of session value in popupcontrolextender in asp.net
问题描述
我在asp.net中使用PopupControlExtender.当我从服务器代码中使用单个DynamicContextKey时,它可以正常工作,但是如果我将其与两个键一起使用时,它将无法正常工作.
我想在PopupControlExtender中使用2 DynamicContextKey并将这2个参数发送到Web方法,它将如何工作.代码如下所示
在页面加载服务器端的c#.net
PopupControlExtender pce = FindControl(" )字符串 behaviorID = " ;
pce.BehaviorID = behaviorID;
pce.DynamicContextKey =会话[" ].ToString()+ ," +会话[ ].ToString();
图片img =(Image)FindControl(" );
字符串 OnMouseOverScript = 字符串 .Format(" $ find('{0}').showPopup();",behaviorID);
字符串 OnMouseOutScript = 字符串 .Format(" $ find('{0}').hidePopup();",behaviorID);
img.Attributes.Add(" ,OnMouseOverScript);
img.Attributes.Add(" ,OnMouseOverScript);
和网络方法是
[System.Web.Services.WebMethodAttribute(),System.Web.Script.Services.ScriptMethodAttribute()]
公共 静态 字符串 GetDynamicContent(字符串 contextKey,字符串结束日期)
{
// string constr ="Server = TestServer; Database = SampleDatabase; uid = test; pwd = test;"; 跨度>
字符串 sConnectionString = 空;
sConnectionString = ConfigurationSettings.AppSettings [" ];
字符串查询= " + enddate + " + contextKey + ',a.emp_leavefrmdate)> = 0)或(DATEDIFF(day,a.emp_leaveenddate,'" + contextKey + " + contextKey + " + enddate + " ;
OleDbConnection conn1;
conn1 = 新 OleDbConnection(sConnectionString);
OleDbDataAdapter odbpc = 新 OleDbDataAdapter(query,conn1);
DataSet dspc = 新 DataSet();
odbpc.Fill(dspc," );
StringBuilder b = 新 StringBuilder();
b.Append(" );
b.Append(" );
b.Append(" );
b.Append(" ); b.Append(" );
b.Append(" );
b.Append(" );
b.Append(" );
b.Append(" );
for ( int i = 0 ; i < dspc.Tables [" ].Rows.Count- 1 ; i ++)
{
b.Append(" );
b.Append(" + dspc.Tables [" ].行[i] [ 0 ].ToString()+ " );
b.Append(" + dspc.Tables [" ].行[i] [ 1 ].ToString()+ " );
b.Append(" + dspc.Tables [" ].行[i] [ 2 ].ToString()+ " );
b.Append(" + dspc.Tables [" ].行[i] [ 3 ].ToString()+ " );
b.Append(" );
}
b.Append(" );
返回 b.ToString();
}
这是我在html中的设计代码
< cc1:PopupControlExtender ID =" runat 服务器" PopupControlID ="
=" 图片1"
=" 面板1
span> =" GetDynamicContent" 位置 =" >
< /cc1:PopupControlExtender >
如果我在2个参数中使用2个会话值,则无法正常工作.请告诉我如何在Web方法中使用会话值或在Web方法中如何使用2个DynamicContextKey
find('{0}').showPopup();",behaviorID); 字符串 OnMouseOutScript = 字符串 .Format("
find('{0}').hidePopup();",behaviorID); img.Attributes.Add(" ,OnMouseOverScript); img.Attributes.Add(" ,OnMouseOverScript);
和网络方法是
[System.Web.Services.WebMethodAttribute(),System.Web.Script.Services.ScriptMethodAttribute()] 公共 静态 字符串 GetDynamicContent(字符串 contextKey,字符串结束日期) { // string constr ="Server = TestServer; Database = SampleDatabase; uid = test; pwd = test;"; 跨度> 字符串 sConnectionString = 空; sConnectionString = ConfigurationSettings.AppSettings [" ]; 字符串查询= " + enddate + " + contextKey + ',a.emp_leavefrmdate)> = 0)或(DATEDIFF(day,a.emp_leaveenddate,'" + contextKey + " + contextKey + " + enddate + " ; OleDbConnection conn1; conn1 = 新 OleDbConnection(sConnectionString); OleDbDataAdapter odbpc = 新 OleDbDataAdapter(query,conn1); DataSet dspc = 新 DataSet(); odbpc.Fill(dspc," ); StringBuilder b = 新 StringBuilder(); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); b.Append(" ); for ( int i = 0 ; i < dspc.Tables [" ].Rows.Count- 1 ; i ++) { b.Append(" ); b.Append(" + dspc.Tables [" ].行[i] [ 0 ].ToString()+ " ); b.Append(" + dspc.Tables [" ].行[i] [ 1 ].ToString()+ " ); b.Append(" + dspc.Tables [" ].行[i] [ 2 ].ToString()+ " ); b.Append(" + dspc.Tables [" ].行[i] [ 3 ].ToString()+ " ); b.Append(" ); } b.Append(" ); 返回 b.ToString(); }
这是我在html中的设计代码
< cc1:PopupControlExtender ID =" runat 服务器" PopupControlID =" span> =" 图片1" =" 面板1 =" GetDynamicContent" 位置 =" > < /cc1:PopupControlExtender >
如果我在2个参数中使用2个会话值,则无法正常工作.请告诉我如何在Web方法中使用会话值,或者在Web方法中如何必须使用2个DynamicContextKey.
Hi,
I am using PopupControlExtender in asp.net.When I use single DynamicContextKey from server code it works fine but if i am using it with two key it didn''t work.
I want to use 2 DynamicContextKey in PopupControlExtender and send these 2 parameter to web method how it will work.code written below
In page load server side in c#.net
PopupControlExtender pce = FindControl("PopupControlExtender1") as PopupControlExtender;
string behaviorID = "pce_01";
pce.BehaviorID = behaviorID;
pce.DynamicContextKey = Session["stdate"].ToString() + "," + Session["enddate"].ToString();
Image img = (Image)FindControl("Image1");
string OnMouseOverScript = string.Format("$find('{0}').showPopup();", behaviorID);
string OnMouseOutScript = string.Format("$find('{0}').hidePopup();", behaviorID);
img.Attributes.Add("onmouseover", OnMouseOverScript);
img.Attributes.Add("onmouseout", OnMouseOverScript);
And web method is
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string GetDynamicContent(string contextKey,string enddate)
{
//string constr = "Server=TestServer;Database=SampleDatabase;uid=test;pwd=test;";
string sConnectionString = null;
sConnectionString = ConfigurationSettings.AppSettings["jssConnectionString"];
string query = "SELECT a.emp_id, b.emp_name, a.emp_leavereq, a.emp_leavefrmdate, a.emp_leaveenddate FROM tbl_leavereq a INNER JOIN tbl_emplogin b ON a.emp_id = b.emp_id WHERE (DATEDIFF(day, a.emp_leaveenddate, '" + enddate + "') >= 0) AND (DATEDIFF(day, '" + contextKey + "', a.emp_leavefrmdate) >= 0) OR (DATEDIFF(day, a.emp_leaveenddate, '" + contextKey + "') = 0) OR (DATEDIFF(day, a.emp_leavefrmdate, '" + contextKey + "') = 0) OR (DATEDIFF(day, a.emp_leaveenddate, '" + enddate + "') = 0)";
OleDbConnection conn1;
conn1 = new OleDbConnection(sConnectionString);
OleDbDataAdapter odbpc = new OleDbDataAdapter(query, conn1);
DataSet dspc = new DataSet();
odbpc.Fill(dspc, "tbl_leavereq");
StringBuilder b = new StringBuilder();
b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:600px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>");
b.Append("<tr><td colspan='4' style='background-color:#336699; color:white;'>");
b.Append("Leave Detail of other employees"); b.Append("</td></tr>");
b.Append("<tr><td style='width:100px;'>Employee Id</td>");
b.Append("<td style='width:150px;'>Employee Name</td>");
b.Append("<td style='width:150px;'>Leave Start Date</td>");
b.Append("<td style='width:150px;'>Leave End Date</td></tr>");
for (int i = 0; i < dspc.Tables["tbl_leavereq"].Rows.Count - 1; i++)
{
b.Append("<tr>");
b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][0].ToString() + "</td>");
b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][1].ToString() + "</td>");
b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][2].ToString() + "</td>");
b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][3].ToString() + "</td>");
b.Append("</tr>");
}
b.Append("</table>");
return b.ToString();
}
and this is my design code in html
<cc1:PopupControlExtender ID="PopupControlExtender1" runat="server"
PopupControlID="Panel1"
TargetControlID="Image1"
DynamicControlID="Panel1"
DynamicServiceMethod="GetDynamicContent" Position="left">
</cc1:PopupControlExtender>
It didn''t work if i am using 2 session value for 2 parameter.Please tell me how i''ll have to use session value in web method or how i''ll have to use 2 DynamicContextKey in web method
find('{0}').showPopup();", behaviorID); string OnMouseOutScript = string.Format("
find('{0}').hidePopup();", behaviorID); img.Attributes.Add("onmouseover", OnMouseOverScript); img.Attributes.Add("onmouseout", OnMouseOverScript);
And web method is
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string GetDynamicContent(string contextKey,string enddate) { //string constr = "Server=TestServer;Database=SampleDatabase;uid=test;pwd=test;"; string sConnectionString = null; sConnectionString = ConfigurationSettings.AppSettings["jssConnectionString"]; string query = "SELECT a.emp_id, b.emp_name, a.emp_leavereq, a.emp_leavefrmdate, a.emp_leaveenddate FROM tbl_leavereq a INNER JOIN tbl_emplogin b ON a.emp_id = b.emp_id WHERE (DATEDIFF(day, a.emp_leaveenddate, '" + enddate + "') >= 0) AND (DATEDIFF(day, '" + contextKey + "', a.emp_leavefrmdate) >= 0) OR (DATEDIFF(day, a.emp_leaveenddate, '" + contextKey + "') = 0) OR (DATEDIFF(day, a.emp_leavefrmdate, '" + contextKey + "') = 0) OR (DATEDIFF(day, a.emp_leaveenddate, '" + enddate + "') = 0)"; OleDbConnection conn1; conn1 = new OleDbConnection(sConnectionString); OleDbDataAdapter odbpc = new OleDbDataAdapter(query, conn1); DataSet dspc = new DataSet(); odbpc.Fill(dspc, "tbl_leavereq"); StringBuilder b = new StringBuilder(); b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; "); b.Append("width:600px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>"); b.Append("<tr><td colspan='4' style='background-color:#336699; color:white;'>"); b.Append("Leave Detail of other employees"); b.Append("</td></tr>"); b.Append("<tr><td style='width:100px;'>Employee Id</td>"); b.Append("<td style='width:150px;'>Employee Name</td>"); b.Append("<td style='width:150px;'>Leave Start Date</td>"); b.Append("<td style='width:150px;'>Leave End Date</td></tr>"); for (int i = 0; i < dspc.Tables["tbl_leavereq"].Rows.Count - 1; i++) { b.Append("<tr>"); b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][0].ToString() + "</td>"); b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][1].ToString() + "</td>"); b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][2].ToString() + "</td>"); b.Append("<td align='center'>" + dspc.Tables["tbl_leavereq"].Rows[i][3].ToString() + "</td>"); b.Append("</tr>"); } b.Append("</table>"); return b.ToString(); }
and this is my design code in html
<cc1:PopupControlExtender ID="PopupControlExtender1" runat="server" PopupControlID="Panel1" TargetControlID="Image1" DynamicControlID="Panel1" DynamicServiceMethod="GetDynamicContent" Position="left"> </cc1:PopupControlExtender>
It didn''t work if i am using 2 session value for 2 parameter.Please tell me how i''ll have to use session value in web method or how i''ll have to use 2 DynamicContextKey in web method
这篇关于在asp.net中的popupcontrolextender中使用会话值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!