Web Forms :: Passing Parameters To ExpressionBuilder
Nov 8, 2010
I have a custom ExpressionBuilder in whixh I'm trying to add a list of optional parameters. My method would be declared as follows:
public static string GetResource(string expression, params object[] parameters) { }
The way I'm calling this method from an ASP.NET page is this at the moment:
<ext:Button ID="btnEdit" runat="server" Text="<%$ AppResources : edit_text %>">
Does anyone know how to perform this method call, but using optional parameters?
I have a page with a lot of pictures on it. I want the user to be able to click on the picture and either bring up a popup type of window passing it the Param name and value , or to have the picture be replaced with this object.
passing parameters from a datalist to another page.
this is how my app works:
i have a database ( access) a table with the following columns: id,title,desc,photo.
another table with the following columns: (startsin, endsin,price,tId)
on the first page (tourpack.aspx) i have a datalist, when user clicks on a button that is in the templateitem of the datalist, he will be transfered to another page called (showtour.aspx). what im trying to do is passing the ID parameter from the first page (table 1) to the second page (showtour.aspx) with the id number so he can see the specific details of that "tour" that are located In the second table.
I am trying to pass the parameters dynamically thru Sqldatasource and get the results in grid view. Based on the dropdown list selection it has to show the results in grid view. When I hard code its giving correct results but when passing thru parameters i'm unable to get the results in grid view.
Output shud be something like this:
Select the value: 123
124
125.
Lets say user selects '123', the query it runs in sqldatasource is Select col1,col2,col3 from table1 where col1 LIKE '123%'
results will be 12301,12302,12303 with other columns in grid view.
If I want to use a CheckBox control to set a parameter and pass it to another page in session, should my code behind look like this?
[Code]....
OpenYearRound is the ID attribute of the CheckBox control.Is there a smarter way to do this?What would my code behind look like for a CheckBoxList control? Something like this?
[Code]....
How would I retrieve those values from the session? Like this?
I'm creating a pseudo invoicing system. I've got a webform where users can pick such informaiton as days, companies, etc to pull the information to create the invoice for and then they click a submit button. I'm wondering what the easiest method would be to get this information. I've had success with such commands as:
but how can you pull this information through the SQLDataSource tools? When I choose to alter the "WHERE" in the sql clause to a control items in the previous page are not accessible.
I know how to pass parameters to Reportviewer in LocalReport mode via textboxes on the page where the user enters them and then they click refresh and everything works fine. What I cannot figure out is how to not pass parameters and make the report display everything, which should be the default.
I know I am missing something really obvious on the Report Parameters screen. Does anybody know the secret?
I am currently writing an ASP .NET (Framework 3.5) page that has a Grid View inside it.
One of the columns of this GridView contains only buttons, that if clicked should open a popup dialog.
To open the dialog I wrote the following code on the button's event handler:
[Code]....
Now when I click on any of the buttons the dialog opens just fine, however I need to pass some parameters to the dialog so that they can be displayed inside it. That's why I've encoded a Base 64 string and passed it as an argument of the popup dialog (apparently if I just used the plain string, the dialog would not open because the string contained linefeed characters).
Unfortunately I wasn't able to get the parameter (base 64 string) on the code behind of the popup dialog. How can I do this?
I have added a gridview in my aspx web page. I have added a hyperlink field, to navigate to another page from the gridview. I am getting the error as:
"There was an error rendering the control.
Index(zero based) must be greater than or equal to zero and less than the size of the argument list. "
This is the code i have used:
[Code]....
[Code]....
When i remove the hyperlink, the grid is getting displayed. I know, there is something wrong i have coded in the DataNavigateURLformatstring, but not sure what is wrong.
I want to pass the StudentID,CourseID,ChildImageID with the link as the querystring.
I am trying to pass the value of a dropdownlist to the Update section of a listview. The dropdownlist is bound to one datasource which needs to then pass its selected value to the UpdateCommand sql for another datasource. Here is my code:
According to all I have read my DataNavagateUrlFields string should work but it isn't. The deal is that any one (AssocID) can have multiple AddrID's associated with it. Regardless of which I choose I only get back the first AddrID for that AssocId.
I want to passed stored procedure parameters from crystal report to pass those parameter dynamically by arraylist because user will pass parameters by using data driven web pages (can be different reports with different parameter). how can i pass through parameter array lists to crystal report setreportparameters fields.
My code;
public void ConfigureReports(ArrayList valuesLists,ArrayList parameterLists) { rptReportViewer.RefreshReport(); DataBaseHelper.myReportConnectionInfo = new ConnectionInfo(); DataBaseHelper.defineConnection = null;
I would like to use ASP.NET's ExpressionBuilder syntax to dynamically retrieve domain of static content from an AppSetting.
I am using the following syntax, which does not work:
<img src="<%$Appsettings:STATIC_CONTENT_DOMAIN %>/img/logo.jpg" alt="logo" width="176" height="159" /> FYI, the desired HTML output is: <img src="http://static.myserver.com/img/logo.jpg" alt="logo" width="176" height="159" />
Please note, I cannot use <%= %> syntax because my ASPX page needs to be CompilationMode="never". (The reason I am using ExpressionBuilder syntax is that it works in no-compile pages)
In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently have.
Is this really necessary for security? If so, what exactly is passing parameters? When i google it I get a lot about stored procedures. Is that what I want, I do not know about stored procedures....yet.
EDIT:
Ok, here is what I got. It seems to update the database correctly and eventually I will change the hard coded ints to inputs from a label. confirm if how I did this is not vulnerable to any sql injection or hacks.
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Security; using System.Data; using System.Data.Sql; using System.Data.SqlClient; public partial class Stats : System.Web.UI.Page { public SqlDataReader DataReader; public SqlCommand Command; string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES (@UID, @CL, @LL, @HL);"); //string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 2, 2, 2);"); protected void Page_Load(object sender, EventArgs e) { LabelUserID.Text = Membership.GetUser().ProviderUserKey.ToString(); } protected void Button1_Click(object sender, EventArgs e) { //connect to database MySqlConnection database = new MySqlConnection(); database.CreateConn(); //create command object Command = new SqlCommand(queryString, database.Connection); //add parameters. used to prevent sql injection Command.Parameters.Add("@UID", SqlDbType.UniqueIdentifier); Command.Parameters["@UID"].Value = Membership.GetUser().ProviderUserKey; Command.Parameters.Add("@CL", SqlDbType.Int); Command.Parameters["@CL"].Value = 9; Command.Parameters.Add("@LL", SqlDbType.Int); Command.Parameters["@LL"].Value = 9; Command.Parameters.Add("@HL", SqlDbType.Int); Command.Parameters["@HL"].Value = 9; Command.ExecuteNonQuery(); } }
I have a grid view that populates and displays data at btn click event from the following sql statement in one of the SP:
SELECT
reg_code, pc_serial, act_code FROM user_reg WHERE reg_code=@reg_code
I want to pass parameters to the other Stored procedure when the edit button is clicked in order to update the 2 columns in the specific row at the time. I now how to pass parameters in a regular btn click event or function, but in the case of edit btn in grid view I don't know how to capture data from specific row and then pass it to the SP. Here is Stored Procedure to update the columns (every user always has the same reg code, but may have more than one serial number and activation code, I want to let the user update serial number and then based on the serial number generate new activation code in the SP.):
when i worked in .NET 1.1 i used to pass parameters to user control using the method- (if the name of the usercontrol is "tables")
dim r As tables = CType(Page.LoadControl("~/usercontrol/tables.ascx"), tables)
and calling public property of the usercontrols.
the problem is that i can't the way to do it in 2008 ver of .NET, it is not recognize the usercontrol.... how can i pass parameters to the usercontrol in run time?
i have a dropdownlist with seven different optins like (date, subject, press, cia, media...) and user will select one of the item from the dropdownlist and click on search button to get the results.here is my repository class GetInquires method which accepts 7 parameters but it will pass only one prameters at a time to the storeproc and in case of Date (it will pass both from/to)
I am trying to use a parameter field where there is a subreport in my main report but i keep getting the error "subreport cannot be shown" when running the report.
p.s - I have just set the parameters the same in the subreport as the main report.
[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Json)] public string MyWebMethod(string foo, string bar) { // DataContractJsonSerializer to deserialize foo and bar to // their respective FooClass and BarClass objects. return "{"Message":"Everything is a-ok!"}"; } I'll call it from the client via: var myParams = { "foo":{"name":"Bob Smith", "age":50},"bar":{"color":"blue","size":"large","quantity":2} }; $.ajax({ type: 'POST', url: 'https://mydomain.com/WebServices/TestSvc.asmx/MyWebMethod', data: JSON.stringify(myParams), contentType: 'application/json; charset=utf-8', dataType: 'json', success: function (response, status) { alert('Yay!'); }, error: function (xhr, err) { alert('Boo-urns!'); } }); However, this yields the following error (a breakpoint on the first line in MyWebMethod() is never hit): {"Message":"No parameterless constructor defined for type of u0027System.Stringu0027.","StackTrace":" at System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2 dictionary, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object o, Type type, JavaScriptSerializer serializer, Boolean throwOnError, Object& convertedObject) at System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2 rawParams) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.MissingMethodException"}
I'd like to pass in two string parameters and use DataContractJsonSerializer to write new Foo and Bar objects. Am I missing something?
I am creating a DataSet to attach to a report (*.rdlc). In the DataSet is a TableAdapter that has the GetData(@start, @end) function. Can someone please explain how I get values in to @start and @end? I have searched and seen that it might have something to do with overriding the Fill function in the DataSet code behind file. Please let me know.