我在C#中有以下代码
Dictionary<string, object> dObject = new Dictionary<string, object>();
Run Code Online (Sandbox Code Playgroud)
我想转换dObject为Dictionary<string, string>.我怎样才能做到这一点?
我正在使用JQuery ajax jsonp.我有以下JQuery代码:
$.ajax({
type:"GET",
url: "Login.aspx", // Send the login info to this page
data: str,
dataType: "jsonp",
timeout: 200000,
jsonp:"skywardDetails",
success: function(result)
{
// Show 'Submit' Button
$('#loginButton').show();
// Hide Gif Spinning Rotator
$('#ajaxloading').hide();
}
});
Run Code Online (Sandbox Code Playgroud)
上面的代码工作正常,我只想将请求发送为"POST"而不是"GET",请建议我如何实现这一点.
谢谢
我在web.config文件中有以下示例代码.
<configuration>
<configSections>
<section name="secureAppSettings" type="System.Configuration.NameValueSectionHandler, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</configSections>
<secureAppSettings>
<add key="userName" value="username"/>
<add key="userPassword" value="password"/>
</secureAppSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我的新部分secureAppSettings已解密,其中有两个键.
现在在我的代码中,我想访问以下这些关键字:
string userName = System.Configuration.ConfigurationManager.secureAppSettings["userName"];
string userPassword = System.Configuration.ConfigurationManager.secureAppSettings["userPassword"];
Run Code Online (Sandbox Code Playgroud)
但它正在回归secureAppSettings这些领域.
我怎样才能获得价值?
我在c#4.0中有以下代码.
//Dictionary object with Key as string and Value as List of Component type object
Dictionary<String, List<Component>> dic = new Dictionary<String, List<Component>>();
//Here I am trying to do the loping for List<Component>
foreach (List<Component> lstComp in dic.Values.ToList())
{
// Below I am trying to get first component from the lstComp object.
// Can we achieve same thing using LINQ?
// Which one will give more performance as well as good object handling?
Component depCountry = lstComp[0].ComponentValue("Dep");
}
Run Code Online (Sandbox Code Playgroud) 我想编写JQuery,它将查找是否在页面上存在Class ="Mandatory",如果任何元素具有此类,则只执行某些操作.
谢谢
我在Web.config中有以下条目,我使用.NET 2.0和C#进行编码.
<add key="userName" value="s752549"/>
<add key="userPassword" value="Delhi@007"/>
Run Code Online (Sandbox Code Playgroud)
现在我希望这个加密,以便没有人能看到它,而且这些密码也可能经常更改(每十五天).
我正在使用C#
我试图检查我的登录尝试是否不超过3,我的意思是以下条件
if (((int)Session["LoginAttempt"]) != 3)
{
}
Run Code Online (Sandbox Code Playgroud)
在登录失败的情况下,我正在执行如下增量:
Session["LoginAttempt"] = ((int) Session["LoginAttempt"]) + 1;
Run Code Online (Sandbox Code Playgroud)
但它给了我错误"对象引用未设置为对象的实例".
请指教!
我有以下html:
<div class="threeimages" id="txtCss">
<a>
<img alt="Australia" src="/Images/Services%20button_tcm7-9688.gif"/>
</a>
<div class="text" id="txtLink">
<h2>
<a href="/partnerzone/downloadarea/school-information/australia/index.aspx">Australia</a>
</h2>
<p>Land of the sunshine!</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
现在,如果你看到div ID"txtLink"中有href,即澳大利亚
我想在页面的运行时将相同的href值复制到div ID"txtCss"的上面标签中,我的意思是当我的页面显示时我的html将如下所示:
<div class="threeimages" id="txtCss">
<a href="/partnerzone/downloadarea/school-information/australia/index.aspx">
<img alt="Australia" src="/Images/Services%20button_tcm7-9688.gif"/>
</a>
<div class="text" id="txtLink">
<h2>
<a href="/partnerzone/downloadarea/school-information/australia/index.aspx">Australia</a>
</h2>
<p>Land of the sunshine!</p>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
请为上述问题提出一些代码
我正在使用C#进行编程.
我面临的问题是,我的隐藏变量值在更新面板中时没有更新.请参阅下面的aspx代码:
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:Timer ID="Timer1" runat="server" Interval="10000" OnTick="Timer1_Tick">
</asp:Timer>
<input type="hidden" runat="server" id="hidCurrentDate" value="" />
<input type="hidden" runat="server" id="hidTripIds" value="" />
<input type="hidden" runat="server" id="hidTripDetails" value="" />
<asp:UpdateProgress ID="uprogTrips" runat="server">
<ProgressTemplate>
<span style="display: block; text-align: center">
<p style="font-family: Verdana; font-size: larger; font-weight: bold;">
<img src="../../Images/ajax-loader.gif" alt="Processing..." /><br />
<br />
Processing...</p>
</span>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanel ID="upTripsGrid" runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView ID="gvAllTrips" runat="server" OnRowDataBound="gvAllTrips_RowDataBound"
OnPageIndexChanging="gvAllTrips_PageIndexChanging" AllowPaging="true" AutoGenerateColumns="false">
<PagerSettings Mode="NumericFirstLast" PageButtonCount="35" Position="TopAndBottom" />
<PagerStyle CssClass="GridPager" />
</asp:GridView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用c#2.0编写一个控制台应用程序,它将使用我的webservice并返回webmethod的结果.
在我的C#代码中,我可以从web方法中获取我的值,请参阅下面的示例代码:
// print results
try
{
Type objtype = Type.GetType(crisresult.ToString());
object obj = Activator.CreateInstance(objtype);
Object[] mArgs = new Object[methodArgs.Length + 1];
methodArgs.CopyTo(mArgs, 0);
mArgs.SetValue(obj, methodArgs.Length);
methodArgs = mArgs;
Object result = mi.Invoke(service, methodArgs);
Console.WriteLine(result);
}
catch (Exception e)
{
Console.WriteLine("Error invoking method '" + methodName + "'");
Console.WriteLine(e);
}
Console.WriteLine("Press enter to continue...");
Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)
现在在上面的代码中,我的webmethod的结果完全以JSON Type返回,所以我Object result有JSON类型的值,例如:
{"FullName":"Mr Mahesh Sharma","Miles":0,"TierStatus":"IO","TierMiles":0,"MilesExpiry":0,"ExpiryDate":"30/03/2012 00:00:00","AccessToken":"106C9FD143AFA6198A9EBDC8B9CC0FB2CE867356222D21D45B16BEEB9A7F390B5E226665851D6DB9","ActiveCardNo":"00300452124","PersonID":8654110}
Run Code Online (Sandbox Code Playgroud)
以上结果,我想在控制台中打印以下格式:
FullName: Mr Mahesh Sharma
Miles: 0
TierStatus: IO
TierMiles:0
MilesExpiry:0
ExpiryDate:31 March 2012
AccessToken: 106C9FD143AFA6198A9EBDC8B9CC0FB2CE867356222D21D45B16BEEB9A7F390B5E226665851D6DB9 …Run Code Online (Sandbox Code Playgroud)