How To Access Args Parameters In Function
Oct 25, 2010I want to set ASP.net custom validator error parameter text through client side javascript. How can access it via sender, args parameters in my function?
View 1 RepliesI want to set ASP.net custom validator error parameter text through client side javascript. How can access it via sender, args parameters in my function?
View 1 Repliesi would like to use script manager and update panel in different domain to accommodate an other domain web site inside a iframe, but it prompts me a an error alert box (An error has occurred in this dialog. Error: 54 Permission Denied), may i know why?
Is that any solution to solve the problem?
Secondly, in the different domain, the JavaScript function EndRequest(sender, args) is not work after finish the loading whereas the InitializeRequest(sender, args) is work. May i know why?
In my application if I get an exception I catch it and send stackTrace through email. I also need the values of parameters passed to this function. I can get the names of function and parameters using MethodBase class of System.Reflection.
View 7 Repliesso I have a web programming assignment for university where I'm building a website that uses an Access database but I have hit a brick wall with something.I'm using parameterized queries to query my database. For one of my queries, I want to be able to take a bunch of parameters that are optional, and if they aren't needed I'll pass in a value of null and I'd like the part of the where clause relevant to them to evaluate to true. This is straightforward in most databases, from my understanding you could do something like to make param1 an optional parameter.
WHERE ((@param1 = ARandomColumnName) OR (@param1 = null))
However this can't be done using Access, as all parameters in a query are represented by a ?. Every ? is assumed to refer to a different parameter, so if you want to use a parameter more than one (like the above code I wrote does) then you'd have to pass it twice. This seems hacky to meSo what do I do? I have spent *hours* googling and banging my head on the desk. I'll cry if I missed something really obvious
I have a page like this In my SQL, I want calculate some value between these days And this is my code;
strQuery = @"SELECT B.HESAP_NO, A.TEKLIF_NO1 + '/' + A.TEKLIF_NO2 AS 'TEKLIF',
B.MUS_K_ISIM, CONVERT(VARCHAR(10),A.ISL_TAR,103) AS 'TARIH',
SUM(ISNULL(CAST(A.ODENEN_ANAPARA AS FLOAT),0)+ISNULL(CAST(A.FAIZ AS FLOAT),0)+
ISNULL(CAST(A.BSMV AS FLOAT),0)+ISNULL(CAST(A.GECIKME_FAIZ AS FLOAT),0)+
ISNULL(CAST(A.GECIKME_BSMV AS FLOAT),0)) AS 'YATAN',
(CASE WHEN B.DOVIZ_KOD = 21 THEN 'EUR' WHEN B.DOVIZ_KOD = 2 THEN 'USD' WHEN B.DOVIZ_KOD = 1 THEN 'TL' END) AS 'KUR',
D.AVUKAT,
(CASE WHEN D.HESAP IN (SELECT T_HESAP_NO FROM TAKIP) THEN
(SELECT ICRA_TAR FROM TAKIP WHERE T_HESAP_NO = D.HESAP)
ELSE ' ' END) AS 'ICRA TARİHİ',
(CASE WHEN D.HESAP IN (SELECT T_HESAP_NO FROM TAKIP) THEN
(SELECT HACIZ_TAR FROM TAKIP WHERE T_HESAP_NO = D.HESAP)
ELSE '' END) AS 'HACİZ TARİHİ'
FROM YAZ..MARDATA.BIR_TAHSIL A, YAZ..MARDATA.S_TEKLIF B, AVUKAT D
WHERE A.TEKLIF_NO1 = B.TEKLIF_NO1
AND A.TEKLIF_NO2 = B.TEKLIF_NO2
AND B.HESAP_NO = D.HESAP
AND A.HESAP_NO = D.HESAP ";
if (txtBoxText1 != "")
{
strQuery = strQuery + " AND A.ISL_TAR >= @S_TARIH_B";
dt_stb = DateTime.Parse(txtBoxText1);
myCommand.Parameters.AddWithValue("@S_TARIH_B", dt_stb);
}
if (txtBoxText2 != "")
{
strQuery = strQuery + " AND A.ISL_TAR <= @S_TARIH_S";
dt_sts = DateTime.Parse(txtBoxText2);
myCommand.Parameters.AddWithValue("@S_TARIH_S", dt_sts);
}
strQuery = strQuery + " GROUP BY B.HESAP_NO, A.TEKLIF_NO1 + '/' + A.TEKLIF_NO2,A.ISL_TAR,B.DOVIZ_KOD ,B.MUS_K_ISIM, D.AVUKAT, D.HESAP";
And this is my Function;
ALTER FUNCTION [dbo].[fngcodeme]
(
@HESAP INT,@BAS DATE, @BIT DATE,@DOV INT
)
RETURNS FLOAT
AS
BEGIN
RETURN(
SELECT SUM(TUTAR)
FROM YAZ..MARDATA.M_GHAREKET
WHERE TEMEL_HESAP = @HESAP
AND DOVIZ_KOD = @DOV
AND REF_KOD = 'GC'
AND BACAK_GRUP = 'PERT'
AND ISL_KOD = 1
AND ISL_TAR >= @BAS
AND ISL_TAR <= @BIT
)
END
What I want getting a value in this code with this function. @BAS is Start Date, @BIT is End Date How can I associate @BAS with Textbox1 and @BIT with Textbox2 ?
This is my first foray into jquery. I wrote a function that will wrap four sides and four corners around a div, effectively placing a border around a box. I would like to pass in height, width, and a third parameter to indicate hoe much padding that particular box should get. How can I do this?
<script type="text/javascript" src="/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$(".smallBox").wrap("<div class='sbox-top'>" +
"<div class='sbox-bottom'>" +
"<div class='sbox-left'>" +
"<div class='sbox-right'>" +
"<div class='sbox-tl'>" +
"<div class='sbox-tr'>" +
"<div class='sbox-bl'>" +
"<div class='sbox-br' style='padding:5px 5px;'>" +
"<div style='background-color: #f2f0f1;padding:0 5px;'>" +
"</div></div></div></div></div></div></div></div>");
});
</script>
internal static void GetUserData(int userId, out string userName,
out string userEmail, out string userPassword)
{
using (SqlConnection con = Util.GetConnection())
{
con.Open();
using (SqlCommand cmd = new SqlCommand("usp_UD_SelectById", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UD_ID", SqlDbType.Int).Value = userId;
cmd.Parameters.Add("@UD_UserName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Password", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Email", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
userName = Convert.ToString(cmd.Parameters["@UD_UserName"].Value);
userEmail = Convert.ToString(cmd.Parameters["@UD_Email"].Value);
userPassword = Convert.ToString(cmd.Parameters["@UD_Password"].Value);
}
}
}
and the call
string userEmail;
string userName;
string userPassword;
MemberHelper.GetUserData(userId, out userName, out userEmail, out userPassword);
Sometimes I need to get just one parameter from the out parameters, how can I call the function when I want to get just one:
string userPassword;
MemberHelper.GetUserData(userId,"","",out userPassword);
I'm using AJAX Page Methods, but I can't seem to be able to pass the needed parameters:
function getFavStatus() {
//favs is a list of DOM <imgs> that I want to modify their img.src attribute
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt,setFavImg(favs[i]));
}
}
function setFavImg(fav, response) {
fav.src = response;
}
The problem that I can't figure out is how to use the "response" from PageMethods, AND pass the DOM object to the callback function.
I've also tried doing something like this:
function getFavStatus() {
for (i = 0; i < favs.length; i++) {
PageMethods.isFavorite(favs[i].alt, function (response) {
favs[i].src = response;});
);
}
}
In this case, the response works properly, but i is always > favs.length, because it has already iterated through the loop... Edit: My PageMethods.isFavorite signature is: [System.Web.Services.WebMethod] public static string isFavorite ( string p_id )
i am looking for a function that takes two string parameters
str1 = "hello how are you today mr john"
str2 = "how today"
and in return it shoud highlight the words "how" and "today".
I have an MS SQL function that is called with the following syntax: SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE ClientID = 7 AND LocationName = ''Default'' ', 10) The first parameter passes a specific WHERE clause that is used by the function for one of the internal queries. When I call this function in the front-end C# page, I need to send parameter values for the individual fields inside of the WHERE clause (in this example, both the ClientID & LocationName fields) The current C# code looks like this:
String SQLText = "SELECT Field1, COUNT(*) AS RecordCount FROM GetDecileTable('WHERE
ClientID = @ClientID AND LocationName = @LocationName ',10)";
SqlCommand Cmd = new SqlCommand(SQLText, SqlConnection);
Cmd.Parameters.Add("@ClientID", SqlDbType.Int).Value = 7; // Insert real ClientID
Cmd.Parameters.Add("@LocationName", SqlDbType.NVarChar(20)).Value = "Default";
// Real code uses Location Name from user input
SqlDataReader reader = Cmd.ExecuteReader();
When I do this, I get the following code from SQL profiler:
exec sp_executesql N'SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable
(''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)',
N'@ClientID int,@LocationID nvarchar(20)',
@ClientID=7,@LocationName=N'Default'
When this executes, SQL throws an error that it cannot parse past the first mention of @ClientID stating that the Scalar Variable @ClientID must be defined. If I modify the code to declare the variables first (see below), then I receive an error at the second mention of @ClientID that the variable already exists.
exec sp_executesql N'DECLARE @ClientID int; DECLARE @LocationName nvarchar(20);
SELECT Field1, COUNT(*) as RecordCount FROM GetDecileTable
(''WHERE ClientID = @ClientID AND LocationName = @LocationName '',10)',
N'@ClientID int,@LocationName nvarchar(20)',
@ClientID=7,@LocationName=N'Default'
I know that this method of adding parameters and calling SQL code from C# works well when I am selecting data from tables, but I am not sure how to embed parameters inside of the ' quote marks for the embedded WHERE clause being passed to the function.
Im wonding what the correct syntax is to pass 2 parameters from a Ascx control into a Vb.net function? Heres what I currently have:
<asp:Literal
ID="CommentFooterLiteral1"
Visible='<%# Eval("Approved") Or IsModerator() %>'
Text='<%# FormatFooter(Eval("Anonymous"), Eval("DisplayName"), Eval("CreatedDate")) + "
" + GetModeratorStatus(Eval("UserId")) %>'
runat="server"
/>
The Function "FormatFooter", needs to pass in Anonymous and DisplayName parameters. Anyone know the correct syntax for doing this?
I need to send som parameters to the callback function of my AJAX call, how can i do that: ex.
[Code]....
I am wanting to send 2 parameters from my code-behind (c#) to a javascript function located in the header of the .aspx site.
View 4 RepliesI want to use sum function in access database (not MS SQL) to add array of items in a particular date.For Eg. The Access Database format like
Date
Prod. Name
Value
[code]...
I am trying to run some animation when an update panel is being updated. I have three update panels on my page and only want this to run for one of the updatepanels.
I use the follwing code which works once the page has loaded,on a button click, however I need the animation to run on the initial page load as well. I have tried adding the animation for page load in a Sys.Application.add_init(MyInit); but it doesn't work.
<script type="text/javascript">
var panelsUpdated;
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
Sys.WebForms.PageRequestManager.getInstance().add_initializeRequest(prm_beginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(prm_EndRequest);
function PageLoaded(sender, args)
{
panelsUpdated = args.get_panelsUpdated();
}
// Called when async postback begins
function prm_beginRequest(sender, args) {
for (var i = 0; i < panelsUpdated.length; i++) {
if (panelsUpdated[i].id == "pnlAccordion") {
var panelAccord = $get('viewResults');
panelAccord.style.display = 'none';
currentPostBackElement = "pnlAccordion";
var panelProg = $get('divImage');
panelProg.style.display = '';
}
}
}
// Called when async postback ends
function prm_EndRequest(sender, args) {
for (var i = 0; i < panelsUpdated.length; i++) {
if (panelsUpdated[i].id == "pnlAccordion")
{
// get the divImage and hide it again
var panelProg = $get('divImage');
panelProg.style.display = 'none';
var panelAccord = $get('viewResults');
panelAccord.style.display = 'block';
}
}
}
</script>
What is wrong with this code? I am trying to pass parameters to a WCF function. I couldn't get this to work. I am getting Ajax error.
$.ajax({
url: applicationPath + "/Test.svc/GetData",
type: "POST",
dataType: "json",
data: '{GId":' + sender.get_value() + '"GName":' + sender.get_text() + '"mId":' + testId + '}',
contentType: "application/json; charset=utf-8",
success: function(result)
{
//trying to fill combobox here
},
});
I want to create a function which would have two parameters
public **XYZ** GetOputput(string strToConvert, **ABC**)
What I want from this function, that I will send a string to this function and the datatype in which I want to convert this string [Ex: Int32,Int64, datetime etc..] and the return will be the same as the datatype I have sent as the input parameter.
I want to have something like this in my function:
[code]....
I am using the AsyncFileUpload.
I set the OnClientUploadStarted event to cancel when the file extension doesn't fit using "args.set_cancel(true);"
But I get the following error "Object doesn't support this method"
Bellow the code
[Code]....
Fot some reason the method "set_cancel" is not available at that moment.
I have many locations stored with addresses and longitude/latitude information in my database.I need a function or store procedure which returns only locations near by 10kms of given longitude/latitude parameters.It is not neccesary to be a sql query but I am fine with any other solution.
View 6 RepliesActually used to use Sql server, for that I add parameters like this
com.Parameters.Add("Field1",SqlDbType.Nvarchar,50).value=TextBox1.Text.
that works fine. but while using MSaccess and the datatype for of some table is Memo than how could I use parameter for that i am using System.Data.Odbc. cos here it is easy to do SqlDbType.Nvarcha cos there is shows Nvarchar but not Memo
[Code]....
I have errors in my Insert statement...
I am trying to write a function that can be called to run a stored procedure. I pass the stored procedure name, followed by as many parameters as I need to run the procedure. I am able to do this by using the params keyword, so my function looks something like this;
[Code]....
How can I determine what the data type of the parameter is? Maybe I need to alter the string[] part, above?
How to set defautl value in OleDbCommand Parameters?
In SQL, I can used New SqlTypes.SqlInt64, but in Access, I can't used New OleDbType.BigInt.
[Code]....
Im getting error: No value given for one or more required parameters. in following code. I checked the code n found that if i remove cmd.Parameters.AddWithValue("PERIOD", period); from code and [period] = ? from command text, everything works fine. I am not getting what is wrong with period.
View 6 RepliesI have been given a task of reproducing the issue/testing the unauthorized access to file system through request.param and query string.
For instance i have something like this. request.querystring("blah");
How could somebody pass "../../../b1/b2" in the query string and access file system.
This may be related to cross site scripting.