The above method doesnt looks to be efficient. Since it will call for a postbacl each time... Try this. Listbox sends "all" the selected values as postback to the server side. This hint is enough to get the job done [:)]. So what u need to do is... 1.. before form submit, u need to selecte all the items in the listbox from which u want to read the values. (this will be done in javascript) 2...string str = Request.Form["MySelectedListBox"] 3... "str" will contain "values" of al the items as csv. 4.. string []selectedItems = str.split(','); 5...foreach(string strItem in selectedItems) { //Insert into database. } Please grade the reply.. in case it helped you. Thanks.
mani_iips
Posts
-
Urgent listbox values in Server side. -
Calling JavaScript FunctionI dont think "OnSelectedIndexChanged" is an event in javascript... instead try this::: DrpArtifact.Attributes.Add("OnChange", "return ValidateFunction('" + DrpEntityType.ClientID + "');
-
tool tip for each items in combobox(HTML Control)Hello.. I understand that u need a tooltipe for "each" item in the comboBox. Thats not possible dear, u may do it by some work around like placing a
with multiple textbox, one for each item. and making div behave as comboBox. Even i required the same functionality, but cudnt find any way out. Please post me updated if you get some better answer/solution. Regards.
-
Changing the properties of control used in Web User Control from Web Form"Randz" answered what i was gng to write. Thats the best way for doing the required job. BUt i hope u understand the consequence of making a control's (visible=false), setting this property to false "stops" a control being rendered. That is, it wont be available to client side (javascript also).
-
Focusing a HTML button in Javascript..Hello.. i am not very sure how asp.net renders the image button into the html. But anyhow u can try this..
//on preRender myImageButton.attributes.add("type", "submit");
On pressing enter key, the Form.Submit event is fired. By assosiaciting the above attribute with ur image buttong it will work if the Image Button is renndered as , but otherwise too u can use the same understanding to get the job done. Keep me updated with the same.. Regards. -
Javascript: Handling "select" tags eventThanks for the reply mate. Even i found ways to raise event once a particular item is selected. But there must be "some" way to work upon a particular item , on the basis of mouseover event on a particular item. The comboBox must be selected indeed, but when its opened, then i want to raise event on "each" item within it as the mouce is moved over it. [What all i am looking for] One may notice that even the browser internally raises some event as the mouse is moved over the items. Since the item under the mouse is displayed in different color. There must be something like that in javascript as well.
-
Javascript: Handling "select" tags eventHello all, Lately i have been looking for a way to get the values (option[n].value) under the mouse (mouseover event) from a javascript function. But i failed miserably. I tried various possible events (onFocus, MouseOver ) but am not being able to get the value of a particular option. Its only giving me the one that is selected. I want to know the value of a particular item (ListItem / option ) which is under the mouse at a particular instance and want to change its colur. Any help/reference/Discussion wud be of real help. Thanks in advance.
-
Fetching Value From a runtime textboxThanks a lot for the reply. I understand what the code is doing is, its loading the textbox again in each page load so as to keep its existence thru the round trips. The solution is perfectly fine but i didnt wanted that to happen. I dont want to reload the textbox once the "save" button is clicked. To be pertinent, I want to know is there a way to "manuallly" catch the values stored in the PostBackData... i know abt _doPostback event, but then how to write a "generic" method which can keep track on the values of a desired control. [:|]
-
Fetching Value From a runtime textboxI have created a textbox on button click event :
protected void btnCreateTextBox_Click(object sender, EventArgs e) { TextBox txtDynamic = new TextBox(); txtDynamic.ID = "txtDynamic"; pnlContainer.Controls.Add(txtDynamic); }
and when the page loads, i click on the button to load the textbox at runtime, it works fine. The problem in in fetching the value of the textbox when the user clicks on the "save" button. I am trying this, but it doesnt works. Since after the postback, there is NO existence of the runtime textbox.protected void btnSaveTextBox_Click(object sender, EventArgs e) { Response.Write(GetDynamicTextValue()); } private string GetDynamicTextValue() { foreach (Control ctrl in pnlContainer.Controls) { if (ctrl.GetType() == typeof(TextBox)) { return ((TextBox)ctrl).Text; } } return string.Empty; }
Here is body of my aspx pageI understand the problem is related to page life cycle, but am not being able to resolve it. Could somebody please explain me the same OR write the "GetDynamicTextValue()" method for me. Any help/referrence/discussion will be of real help. Am really stucked into an application that needs this utility. Thanks a lot for reading.
-
accessing all controls of a page..Within "foreach" you can "access" all the controls.. but you can not change the state of objects within. If that is the requirement, then you better access them usin "for" loop and access the controls using indexes. In case, it doesnt answers your questions. PLease be more elaborate about the same. Regards.
-
Working with PDF.Hello all, I need an application which can read a given pdf (with multiple pages)and break it into multiple files on a given parameter. The first objective is to develop and application which can read the whole pdf word by word into a stream, and writing the same stream into another pdf. If someone has done any work on that, then please share the same or any apropos information.
-
Connecting to SQL !!!Most welcome Mr K. Since am quite new to scores here.. wud really appreciate if you grade my reply and articles. :)
-
Connecting to SQL !!!The error is self explanatory. You havent set the connection property for "MyCmd" i.e. sqlCommand. Not very sure about VB syntax, but you need to do something like. "MyCmd.Connection = MyConn " It shud solve problem.
-
Can Someone Explain this (ref Page Life Cycle)I have made a user control ( text.ascx) with a text box (txtUserControl) and a button (btnUserControl) .
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="test.ascx.cs" Inherits="WebApplication1.test" %>
Now i load this usercontrol dynamically on (default.aspx) into two panels:public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { test tst = Page.LoadControl(@"~\test.ascx") as test; pnlDefaultOne.Controls.Add(tst); } protected void btnDefault_Click(object sender, EventArgs e) { test tst = Page.LoadControl(@"~\test.ascx") as test; pnlDefaultTwo.Controls.Add(tst); } }
Now, the question is about the beahviour of textbox (txtUserControl), and its viewstate. When i click btnDefault.. it loads the userControl in panelTwo. now when i enter values in both the textboxes (each of a usercontrol), and click the btnDefault, the value in the first control (the one loaded at page_load) is persisted, while in the other one which was loaded in btnEvent is NOT. i have read decent enough abt page cycle and am aware abt rendering, viewstate, postBackData. BUt cant really figure out the reason behind this. Any comment on the same will be of help. Thanks in advance. -
Working Behind Boxing/UnboxingHello. Have been trying to search for the real working behind the concept of boxing/unboxing. I understand the concept and its utility, but dont know what exactly happens behind the scene as per memory address and the apropos changes in the stack and heap memory. Any information or reference will be of help. Thanks.
-
How to send variable from aspx.cs page to aspx pageHello. am trying to set a value from aspx.cs page (string str) and then want to access that value in the aspx page. Please let me know how to do that.