|
Thanks for the clarification on the subject.
I still have more to learn here.
So I don't' need the conn.close() then, since using will close the connection for me.
And if the query is correct, then I don't need try catch.
Alright, I get it now.
|
|
|
|
|
The Veracode Scaner finally did not find this as an SQL injection error. The final fix:
namespace TAMIS.Business.Common
{
public class MyParam
{
public SqlParameter SqlParam { get; set; }
public string Name { get; set; }
public object Value { get; set; }
public int Type { get; set; }
}
public class QueryContainer
{
string _query;
public List<myparam> parameterList = new List<myparam>();
public QueryContainer(string query) { _query = query; }
public SqlDbType AddParameterType(int type)
{
switch (type)
{
case 1:
return (SqlDbType) Enum.Parse( typeof(SqlDbType) , "int" , true );
case 2:
return (SqlDbType)Enum.Parse(typeof(SqlDbType), "NVarChar", true);
}
return SqlDbType.VarChar;
}
public string Query
{
get
{
return _query;
}
set { _query = value; }
}
}
public int GetAccountSortByAccountCode(int account)
{
QueryContainer Instance = new QueryContainer("SELECT ac_sort_order FROM lkup_account_codes where ac_code = <a href="http:
MyParam myParam = new MyParam();
myParam.SqlParam = new SqlParameter("@account", Instance.AddParameterType(1));
myParam.SqlParam.Value = account;
Instance.parameterList.Add(myParam);
return Convert.ToInt32(ExecuteScaler(Instance, 1));
protected Object ExecuteScaler(QueryContainer Instance, int i)
{
object returnValue = null;
if (!_iserror)
{
if (_trace)
{
}
if (_connection == null || _connection.State == ConnectionState.Closed)
{
OpenConnection();
}
DbCommand command = _provider.CreateCommand();
command.Connection = _connection;
{
command.CommandText = Instance.Query;
command.CommandType = CommandType.Text;
foreach (var p in Instance.parameterList)
{
command.Parameters.Add(p.SqlParam);
}
if (_useTransaction) { command.Transaction = _transaction; }
try
{
returnValue = command.ExecuteScalar();
}
catch (Exception ex)
{
if (ex is EntryPointNotFoundException)
throw ex;
RollBack();
LogBLL bll = new LogBLL();
bll.WriteErrorLog(ex);
_iserror = true;
}
finally
{
if ((!KeepAlive && _connection.State == ConnectionState.Open) || _iserror == true)
{
CloseConnection();
}
}
}
}
else
{
returnValue = -1;
}
return returnValue;
}
<pre>
modified 21-May-15 11:18am.
|
|
|
|
|
Hi I'm using JQuery AJAX to call a web service and this webservice gets data from a database. Everything seems fine; I was able to get the data that the web service got from a database and display it on the front end.
The problem is when I deploy my application to IIS, my ajax calls returns "Request Failed!" which indicates that it cannot communicate with my web service. The following is my AJAX
$.ajax({
type: "post",
url: 'h t t p: // localhost:48690/MyWebService.asmx/MyWebserviceMethod',
data: JSON.stringify({newText: newText, pageURL: pageURl }),
contentType: "Application/json; charset=utf-8",
dataType: "json",
success: function (response) {
alert(response);
},
error: function (response, status) {
alert('Request Failed!');
}
});<br />
My question is, is there anything wrong with the way I write my URL in the AJAX method, if not what do you think is causing my web service to fail when I deploy my app.
If you are wondering why there are gaps in "http" in my url, that is so I can dispay my message without the anchor tag getting added to my post automatically. Thanks in advance for your replies.
modified 15-May-15 5:19am.
|
|
|
|
|
You're requesting localhost:48690 in your code, so chances are your call is failing due to cross-domain issues. Drop the host from the url so it requests from the current domain
url: '/MyWebService.asmx/MyWebserviceMethod',
|
|
|
|
|
label field will not update in database
control is :
<asp:label id="RiskRatingLabel" runat="server" text="<%# Bind("RISKST_Description") %>" cssclass="RiskRatingLabel" forecolor="Black" font-bold="true">
jquery updates the label via onchange events of other controls:
$('.RiskRatingLabel').text(RatedRiskText);
change is visible in page on certain events firing
controlparameter used in update statement:
<asp:controlparameter name="RiskRatingLabel" controlid="FormView1$RiskRatingLabel" propertyname="Text" type="String">
updatecommand = "update table set field1 = @value1, field2 = @value2, etc,...,
RiskRating = @RiskRatingLabel, etc...
This particular field as well as many other fields are Nullable,
all other fields are being updated except this one...
I can see the label value being updated on the page, yet it doesn't seem to pass through to the update command...
Any ideas?
|
|
|
|
|
Labels aren't form controls, they are not sent to the server when you submit a form. Use an asp:Hidden element to store your new data (you can still keep your label and update that, but you also need to update the value of the hidden variable). When the form is submitted you can read the data from your hidden variable.
|
|
|
|
|
Hello,
I need to upload files to a location that supports WebDav connection. How can I do that using C#/ASP.NET?
Thanks.
|
|
|
|
|
|
Hi guys,
I am looking to develop an ASP.Net application that will allow a user to reset Windows domain passwords for anyone they are the manager of. For example: Finance manager can reset the password of anyone he is listed as a manager of in Active Directory.
I was wondering what the best way to do this was in terms of accessing Active Directory. Should I have a service account created which I call using my code, should I give all users access to reset AD passwords (they are unable to install software - like RSAT - on their terminals so this seems pretty safe), or should I use a third method I am not aware of?
If anyone could please tell me the best solution for this that would be great.
Thanks!
|
|
|
|
|
Hi,
Here's my ASPX page:
<Quote:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/DEF.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<asp:content id="Content2" contentplaceholderid="PlaceHolderBodyAreaClass" runat="server">
<asp:content id="Content1" contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
<script type="text/javascript" src="Scripts/js/jquery-1.11.2.js"></script>
<script type="text/javascript" src="Scripts/js/jquery-ui.js"></script>
<asp:content id="BodyContent" contentplaceholderid="PlaceHolderMain" runat="server">
<asp:updatepanel id="UpdatePanel4" runat="server">
<contenttemplate>
<asp:label id="lblError" runat="server" forecolor="Red" text="">
<asp:button clientidmode="Static" id="Button1" runat="server" text="DIALOG"
="" onclientclick="Dlg();return false;">
<asp:updatepanel id="UpdatePanel6" runat="server">
<contenttemplate>
Group: | <asp:textbox id="txtGroup" runat="server">
| <asp:button id="btnQuestSave" runat="server" usesubmitbehavior="false" text="Save ASYNC" onclick="btnQuestSave_Click">
|
<script type="text/javascript">
function Dlg()
{
$('#dialogQuests').dialog({ minWidth: 840, resizable: true });
}
</script>
When I click on "Save ASYNC" button txtGroup comes empty in btnQuestSave_Click. I wonder what's wrong with my project.
|
|
|
|
|
I look at the top code block, and there are no input elements to send back to the server, called submit.
You can only submit input elements, that have to be inside the update panel.
Plus on the button, it said run the client script, and return false , canceling the the submit.
So a round trip to the server will never occur.
I don't know what to make of the bottom code, looks worst than the top code block.
But you turn off submit behavior, so it would fire the update panel.
|
|
|
|
|
Yes, I want to have my txtGroup submitted along with btnQuestSave click. And this textbox is located in the same updatepanel with the button. Regarding another button, Button1, I didn't need it to produce submit, only dlgbox popup.
|
|
|
|
|
The solution is HERE
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
var elId = sender._activeElement.id;
if (elId.indexOf("btnAddTypeQuest") > -1 || elId.indexOf("btnEditQuest") > -1) {
$('#dialogQuests').dialog({
maxHeight: 600,
minWidth: 840,
open: function (type, data) {
$(this).parent().appendTo("form");
}
});
}
if (args.get_error() != undefined) {
args.set_errorHandled(true);
}
}
The crucial thing is in bold
|
|
|
|
|
when I go back home , the default.aspx has also written within domain name.
for example:-
http://www.domaindname.com/default.aspx
how to remove default.aspx to the domain name.
|
|
|
|
|
Why do you want to? People can still type in http://www.domainname.com/ and it works, right? Who cares if default.aspx gets added on? You do have to load a page.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I mean to say for example when I open asp.net c# website in local host the Default.apx page is also written within local host how to remove Default.aspx from the local host
http://localhost:50050/Default.aspx
in above line Default.aspx remove the main page.
|
|
|
|
|
I care.
It is plain ugly.
In this case there is no use in having two URI's pointing to the same resource.
When people can, they will keep links around to the URI including the aspx bit. Which means that all those links go broken should I change the default to index or whatever.
Having the default.aspx bit reveals details about the implementation that are totally irrelevant to visitors.
And those details do not serve any purpose other than increasing the burden of changing the technology stack implementing a site and that means increasing the lock-in with that technology (in other words: increasing the inertia with regard to changing it).
Pretty url's do not exist for the sole reason of being pretty...
---
http://softwareonastring.com
|
|
|
|
|
URL rewriting may be what you want then.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
How can i Add Dynamic Field in Database or XML File , when we add any Control into the Page in MVC 4.0. and when we add or Delete the new Field then no any effect made on Previous Entered Record.
Please Help me ,Very Important
|
|
|
|
|
Your question is far from being precise enough to be answered. If it's so important for you, you should take the time to explain it properly.
If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson
|
|
|
|
|
columns are static in a table, unless you add or delete one.
if you need something dynamic, then write XML to a column designed to store XML in your table.
Or write a CSV file or something.
I store shipping data and options that are always different in a XML file stored in a column in a table.
So I just write the XML, and then parse it.
Other than that, I think your proposed solution needs another looking at.
Instead of deciding to do something that may not be plausible, you should check to see if it can be done first.
|
|
|
|
|
We would need more information to be sure, but usually you want to structure things so that you dynamically add or remove something with a corresponding record in the DB. Not by changing the schema.
For instance you might have a [Control] table, that references a [ControlType] table. So that adding a record in the Control table would correspond to adding a new control on your page.
|
|
|
|
|
Currently I am generating page with Response.Write as below in cs file
public void publishtext()
{
string abc = "<input id=\"text1\" name=\"text1\" />";
Response.Write(abc);
}
in .aspx
<div>
<% publishtext(); %>
<div>
In same way I am trying to publish Ajax control. But unable to view it in runtime.
public void publishtext()
{
string abc = "<cc1:ComboBoxID=\"test1\" runat=\"server\" width=\"50px\" visible=\"true\">";
abc += "<asp:ListItem Text=\"a\" Value =\"a1\"></asp:ListItem>";
abc += "<asp:ListItem Text=\"a2\" Value =\"a2\"></asp:ListItem>";
abc += "<asp:ListItem Text=\"a5\" Value =\"a5\"></asp:ListItem>";
abc += "</cc1:ComboBox> ";
Please let me know how Ajax will work with Response.Write
|
|
|
|
|
|
how to develop video chat in asp.net c#? iam trying for that since 1week am not getting result. can any one help in developing in video chat application.
pls help me.
Thanks in advance.
|
|
|
|