I am writing what i will call a survey system. The surveys will consist of a series of questions, split into sections. The survey definitions will be stored in a database. The questions can be of various types, that have different input methods and validation (e.g.textbox, numeric textbox, selectlist etc.) I am creating a set of user controls that map to different question types. I would like to completely abstract the survey rendering logic from the, survey definition logic. The way i thought i would do this is to use a dumb rendering control that simply takes a collection of controls and renders them out in a for each loop a super simplified version of what I am doing.
This works in the sense that the correct controls get added to the place holder,however nothing renders. Presumably this is because it does not have the markup in the asxc file.
If i do something like this
private void RenderControls()
{
foreach (UserControl CurrentControl in this.ControlsToRender)
{
MyPlaceholder.Controls.Add(this.LoadControl("path to ascx file")
}
}
It will create the correct number of controls, but i don't want to instantiate the controls here because i would need to to set various properties based on cconditional logic i want to abstract away from this pure rendering layer.
what i want to do is instantiate the controls else where, set the relevant properties and then simply pass a collection of these into the rendering control to render out.
Is there a way to do this with user controls? Would i have to create custom controls instead?
First up i would like to apoligize for these questions that are proable realy easy. I have been put on the spot by my boss and have been told to change all my php to asp.net c so it can go in this new cms i have at work. I have just spent the last 18 hours trying to get this to work and im geting a little desperate.
Ok so my current issue is that i dont know how to add html formating to a result string i pull out of my mysql database. I have my result sheet pulling into a gridview, what i want to do is put some information drawn from each row in the gridview out side of the <Tr> tag. Is this possible? But within the Table Tag second issue is it possiple to feed data into a page and then run a mysql query like i was doing in php.
I have a datalist control that is querying a accessdatasource for information that populates the results based on w/e is typed in a textbox. I can't figure out how to pass the information that is populated in the datalist to another page when a button is clicked (inside the datalist item template).
I was able to peform this in Detailsview with a hyperlink using the following arguments:
DataNavigateUrlFieldsDataNavigateUrlFormatStringBut this seems not to exist in Detailsview. Could someone point me in a direction on how to acomplish this?
I'm passing several variables thru the URL and want to use them in several SQL Queries that I want in my asp page. For example one of the (hypotetichal) is client_id and i want to use it in a query to gather other information.
I have gotten alot of help lately on my project and think I only have one more issue that I can't think of how to do. What i'd like to do is pass a login name and password from a Login.asp page to all of my other pages. So for instance if I have a successful login, I am taken to the Home.asp page. But i'm not sure how I can pass the LoginID used from Login.asp to the Home page. Ideally i'd like to use this information in the SQL connection strings, and to customize the Home page to show orders assigned to certain people that are logged in.
I'm trying to pass some variables from one page to another via the session state and then post those variables to labels on page 2. When I try to write the code for my labels on page2, I get an error of "Declaration expected"Here is my code from that page:
Partial Class Default2 Inherits System.Web.UI.Page Dim firstname As String = CType(Session.Item("FirstName"), String) [code]...
Am I missing a page_load event handler or what am I missing?
I have a search page which generates a GridView of results based on the search terms entered by the user. One of the columns in GridView is called a DOI (Document Object Itentifier). This DOI is used to find academic papers through [URL] when a user enters a DOI string. What I would like to do is redirect the user to the relevant webpage when they have selected the DOI in the GridView, however, the url for this page is always different. In the page, I have formatted the form tag like so: [URL] and in my GridView, I have formatted the row that I wish to have hyperlinked like so:
Then, in my C# codebehind, I have the following event which aims to redirect the user to the required page, based on the tag they have selected:
switch (e.CommandName) { case "d": searchResult.Attributes.Add("onchange", "window.open [URL] break; }
I don't think this code above makes any difference though as the form tag is already specifying the redirected url, nor do I think this task can be done with a html <table> object, as it only accepts static data, rather than a result set generated from a database, which is what I'm doing. I have also looked at the following post as a guide to this type of problem but, taking account of what it said didn't allow me to solve this problem completely. GridView with DDL and selected value
Im having problems passing a variable from my c# code behind into my asp as part of a connection string. how do i go about passing in a variable from my code behind into my asp.
VS2010/VB/ASP.NET 4.0 If an error occurs in an ASP app you can redirect it to a default page which is defined in the web.config file How can you pass the variables (URL) to the error webpage then to a logfile or sent via an e-mail address?
Example: 404 Error
- Page hosting the link - URL - Search (if applicable)
I have an asp:hyperlink that links to an iframe. I have set the navigateUrl to the iframe page would also like to pass a variable through to the iframe depending on what button is clicked.
Is there a way to assign/pass/copy a javascript variable to a server side variable in C#? For the sake of argument, let's say that I was able to parse some JSON for variables that I want to store and assign them on the client (ie. var = FirstName and var = 25 and var = someDateTime, etc) .
I am having troubles making the code run. I have a web page with a gridview and a checkbox. I would like the button when selected to pass the category id. I have managed to get it work without paging. Once the paging kicks in see below, I am unable to run the code. see below.
I am designing a page for my students to practice their Latin vocabulary. I am having two problems with the design: 1) working with checkboxes, and 2) display one returned row at a time. 1) First, students select from CheckListBox1 those parts of speech (nouns, verbs, adjectives, etc.) they want to review, and then they click Button1 ("Submit"), which fires off a SELECT statement against a table named CoreVocab in a SQLEXPRESS database. How do I pass each selected part of speech from CheckListBox1 as a variable into the WHERE statement when the user clicks Button1? Do I place this code in the Button1_Click on the .cs page?
2) the table returns the first row and Button1 changes to "Next," which the student then clicks to see the next Latin word. How do I get the Repeater table to show only one row at time until the Next button is clicked? And how do I get the same button to executed two functions (fire off the SELECT statement and then show the next row)? For what it's worth, I'm using the SqlDataReader command, since data will only be retrieved, not modified.
whats the exact use of static variables in overall programming in .net and for asp.net...
Recently i went for the interview where interviewer asked me 2 question which i was not sure for the same..
whats the use of session object, i said sessions are the server side object, they are used when you want to store user specific data at server side, then he asked what if i want to use static variables for the same, i was mum, can anyone tell me how asp.net will behave if i store the user specific information in static variables.If i use cookies which are the best option to store the data at client side (not sensitive one), but what if user has disabled cookies on his machine, will my application would crash.
I have a SQL Server 2000 table that has an insert trigger that e-mails the user when a record is inserted for them. i want to include a link to a page that will disply a list (datagrid) of their records only. What is the best way to do this? The trigger is already completed and currently includes a link that displays all records but I want to be able to narrow that based on the user.
I'm fairly new to MVC and admittedly don't fully understand how data is passed between Views and Controllers. That said, here is my issue.
I am working with C#. I have a page which has a list of items. Each item has a radio button set of three associated with it and there are 15 of these sets on the page. Thus I have radio1, radio2....radio15, etc. Each of these has value 0, 1, or 2 upon submit. I can't seem to understand how to get the information out of these radio button sets from the controller without passing 15 different variables to the post method in the controller which is associated with the view; ie passing Int32 radio1, Int32 radio2,.., Int32 radio15, etc.
I tried using ViewData["radio"+i] in a loop to access the value of each radio button set, but this, apparently can only be used to pass data to the View from the Controller and not the other way around.
I have two user controls both have a repeater and a button. They are both on a .aspx page. I need to capture the values from those two buttons on the user controls in variables on the .aspx page. Right now, I have two labels on the page that I am outputting the values of the buttons to, but they don't have a value right now, which is my problem.
I need to access a variable that is declared in a master page to a child page. I'm using asp.net 2.0 (vb). I'm sure this should be easy and is down to my inexperience with asp.net! A rough guide to my code is below;
MASTER PAGE <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %> <script runat="server"> Public UserNumber As Integer = 3 End Sub </script> CHILD PAGE <%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
I have a page wich opens a popup window. I want to pass some variables, like some textbox.text and 2 dataTables from parent window to the popup window. And then I'll have to return some vars from popup window to parent window. So what is the best way to do this,
I don't know if it's appropiated passing 8 or 10 variables as the option2 because the user will see a very long url with all the variables, but maybe is more efficient than using Sessions.... Anyway, could somebody clear me up?
I have 2 sites, one the main product site the other a secure site featuring the basket and checkout processes.
When a user clicks "add item to basket" I am creating a basket in a database and then adding the items to the basket. The theory was then to store the id from the database for the basket (the basketid) in a cookie, redirect the user to secure site, use the basket id from the cookie and display the contents in the basket.
However I am having trouble getting the secure site to use the same cookie. When I redirect the users to the secure site, the basket appears empty. I need to go back to the main site and then back to secure before the cookie appears.
Here is the code for the cookie
[Code]....
And then on the secure site this is how it gets the basket ID from the cookie
[Code]....
But like I say it's having problems. I've tried replacing the cookies with session variables as well but it didn't work.
I have a user control that contains a reportviewer control.And I want to send an array of reportparameter to my user control.But I can't figure out how to do.I'm getting "Object reference not set to an instance of an object. ".My param_reportParam variable is null in usercontrol.My user control's parameter is like that ;
[Browsable(false)]public ReportParameter[] param_reportParam{ get { return _param_reportParam; } set { _param_reportParam = value; }}private ReportParameter[] _param_reportParam;
And a simple page that uses user control to show server reports is like that ;
ReportParameter[] parameters = new ReportParameter[4];//parameter number can be different parameters[0] = new ReportParameter("imza", imzalayacaklar); parameters[1] = new ReportParameter("Sayi_Son_Eki", "984"); parameters[2] = new ReportParameter("PersonelTip", "2"); parameters[3] = new ReportParameter("parafli", "1"); wuc_rapor_genel1.param_reportParam = parameters;//this is my usercontrol
In my project, I need to create a user control to handle the sorting and pagination of all the grids in the application. The grid however will be different in different pages with different formatting.
I am able to do this by exposing a property from user control which takes gridview as the input.
then in page load, i bind this grid, and assign the sorting and paging event handlers to this gridview variable.
This way I am able to do the sorting and paging, but the problem is I have to bind the grid in all the post backs, and then in the sorting and paging events.
So when a user sorts, I have to bind the grid twice, once in page_load and then in sort event of user control.
I can store the first set of records in viewstate and bind that in page load, but is there any other way, so that i dont need to bind the grid in all post backs but only inside of not postback.