Click here to Skip to main content
15,896,111 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Browser close issue Pin
J Xie12-Oct-10 18:37
J Xie12-Oct-10 18:37 
Questioncommand returning null value Pin
myinstincts20-Oct-09 18:02
myinstincts20-Oct-09 18:02 
AnswerRe: command returning null value Pin
Christian Graus20-Oct-09 19:10
protectorChristian Graus20-Oct-09 19:10 
GeneralRe: command returning null value Pin
Abhijit Jana20-Oct-09 19:18
professionalAbhijit Jana20-Oct-09 19:18 
GeneralRe: command returning null value Pin
Christian Graus20-Oct-09 19:32
protectorChristian Graus20-Oct-09 19:32 
AnswerRe: command returning null value Pin
Abhijit Jana20-Oct-09 19:12
professionalAbhijit Jana20-Oct-09 19:12 
QuestionASP.NET hosted Application FIle Path Problem Localhost Pin
Waleed Butt20-Oct-09 11:59
Waleed Butt20-Oct-09 11:59 
QuestionC# getting Text Box Value of a DEEPLY nested Control Pin
Steve Crochet20-Oct-09 11:57
Steve Crochet20-Oct-09 11:57 
Hello,
This is my first time submitting a question ANYWHERE, please be kind to the noobie.

Situation:
• Creating a NOTING System for indivisual users
• Notes are stored in DB and retrieved for display on the web application
• Notes are grouped by Date entered
• Since notes can be lengthy an abbreviated notes is displayed
• A hover control is created to "show" the full note for reference/editing and deletion
• Nested Parent to Child controls are as follows
> PlaceHolder [ph_your_note] (static created on aspx presentation layer)
--- ALL dynamic cotrols are placed here ---
> pnl_main (created to house nested controls in one panel
> pnl_date (created to hold all notes of one date value)
> hvm_note ( hover control to show the sub panel that displays the full note)
> pnl_sub (created to hold the note header, textbox, update and delete image buttons )
> tb (text box that will be used to Display/Edit returned value of the
full note written to the database)
THIS IS THE CONTROL I AM LOOKING TO RETRIEVE THE VALUE FROM
What I currently know:
• The dynamically created Update Image Button is where I am trying to retrieve the tb.Text value (shown in code snippet below)

• I have located the value of the text box here, through QuickWatch
((System.Web.UI.WebControls.TextBox)(((System.Web.UI.WebControls.PlaceHolder)pnl_your_note.Controls._controls[0]).Controls[23].Controls[1].Controls[0].Controls[1])).Text

>Controls[23] is the varible that I need to determine how to dynamically call

Code snippets:
public void BindNotes()
{
	DataSet ds = Execute_Notes();

	string check_date = "";
	string hold_date = "";
	ph_your_note.Controls.Clear();
	Panel pnl_main = new Panel();
	pnl_main.ID = "pnl_notes_main";

	int i = 0;

	while (i < ds.Tables[0].Rows.Count)
	{
/// ••••••••••••••••••••• CREATION OF ALL CONTROL ELEMENTS ••••••••••••••••••••••••••••••••
	///creates a hidden field to house the id of the interated note (i)
		HiddenField hf = new HiddenField();
		hf.Value = ds.Tables[0].Rows[i]["Note_ID"].ToString();

	///creating a unique value for each element (i)
		notes_id = hf.Value.ToString();

	///Creates new panel to place all notes of one specific date 
		Panel pnl_date = new Panel();
		pnl_date.Attributes.Add("runat", "server");
		pnl_date.ID = "pnl_date_" + hf.Value.ToString();

	///Creates new panel to hold SOMETHING
		Panel pnl_sub = new Panel();
		pnl_sub.Attributes.Add("runat", "server");
		pnl_sub.ID = "pnl_sub_" + hf.Value.ToString();
		pnl_sub.BorderWidth = Unit.Pixel(1);
		pnl_sub.BorderStyle = BorderStyle.Solid;
		pnl_sub.BorderColor = System.Drawing.ColorTranslator.FromHtml("black");

	///create new label to display the abreviated note for refernce on the main screen
		Label lbl_abbreviated = new Label();
		lbl_abbreviated.Attributes.Add("runat", "server");
		lbl_abbreviated.ID = "lbl_abbreviated" + hf.Value.ToString();
		lbl_abbreviated.CssClass = "note_abreviated";

	///creates new label to hold the date barrier header 
		Label lbl_date = new Label();
		lbl_date.Attributes.Add("runat", "server");

	///creates new label to hold a linebreak 
		Label lbl_br = new Label();
		lbl_br.Attributes.Add("runat", "server");
		lbl_br.Text = "<br>";

	///creates new label to hold the sub panel header title
		Label lbl_edit = new Label();
		lbl_edit.Attributes.Add("runat", "server");
		lbl_edit.Text = "<center>view - update - remove <br></center>";

	///creates new label to hold non-breaking spacer elements
		Label lbl_spacer = new Label();
		lbl_spacer.Attributes.Add("runat", "server");
		lbl_spacer.Text = "&nbsp;&nbsp;&nbsp;";

	/// if the note Length is longer than 22 characters, trim and display
		if (ds.Tables[0].Rows[i]["Note"].ToString().Length > 22)
		{
			lbl_abbreviated.Text = "&nbsp;&nbsp;<img id='img_show' src='images/btn_icons/note_edit_16x.png' height='11px' />  " + ds.Tables[0].Rows[i]["Note"].ToString().Substring(0, 22) + ". . .";
		}
		else
		{
			lbl_abbreviated.Text = "&nbsp;&nbsp;<img id='img_show' src='images/btn_icons/note_edit_16x.png' height='11px' />  " + ds.Tables[0].Rows[i]["Note"].ToString();
		}
		check_date = Convert.ToDateTime(ds.Tables[0].Rows[i]["DATE_ENTERED"]).ToString("MMMM d, yyyy");
		if (check_date != hold_date)
		{
			lbl_date.Text = "&nbsp;" + check_date.ToString() + "<br>";
			lbl_date.CssClass = "note_date_seperator";
		/// ADDS the Date to the PANEL DATE CONTROL 
			pnl_date.Controls.Add(lbl_date);
		}

	///Creates a new text box to display the full text content for deletion or edit
		TextBox tb = new TextBox();
		tb.Attributes.Add("runat", "server");
		tb.TextMode = TextBoxMode.MultiLine;
		tb.Width = Unit.Pixel(175);
		tb.Height = Unit.Pixel(150);
		tb.Text = ds.Tables[0].Rows[i]["Note"].ToString();
		tb.ID = "tb_note_" + hf.Value.ToString();
		tb.CssClass = "note_tb_format";

	///Creates image buttons for Edit and Delete events
			ImageButton img_btn_update_edit = new ImageButton();
		///Creates the OnClick Event Handler
			img_btn_update_edit.Click += new ImageClickEventHandler(img_btn_update_note_Click);
			img_btn_update_edit.ImageUrl = "images/btn_icons/note_accept_16x.png";
			img_btn_update_edit.Attributes.Add("runat", "server");
			img_btn_update_edit.ID = "note_" + hf.Value.ToString();
			img_btn_update_edit.CssClass = "note_panel_icons";
			img_btn_update_edit.ToolTip = hf.Value.ToString();
			
			AttributeCollection note = img_btn_update_edit.Attributes;

			ImageButton img_btn_remove = new ImageButton();
			img_btn_remove.ImageUrl = "images/btn_icons/note_remove_16x.png";
			img_btn_remove.CssClass = "note_panel_icons";

	///create hover pop up that displays sub panel with editing and removal options
		//int hover_popup = lbl_abbreviated.Text.Length;
		HoverMenuExtender hvm_note = new HoverMenuExtender();
		hvm_note.TargetControlID += lbl_abbreviated.ID.ToString();
		hvm_note.PopupControlID += pnl_sub.ID.ToString();
		hvm_note.ID = "hvm_note_" + hf.Value.ToString();
		hvm_note.OffsetX = 20;
		hvm_note.PopDelay = 500;


/// •••••••••••••••• FILL ALL CONTROLS ••••••••••••••••••••••••••••••
	/// fill DATE PANEL that show date of notes listed below (1st fill)
		pnl_date.Controls.Add(lbl_abbreviated);
		pnl_date.Controls.Add(hvm_note);

	///fill sub panel whith text and image buttons for administration. (2nd fill)
		// adds sub panel header | Textbox with Note | hard line break | Update Image Button | Delete Image Button 
		pnl_sub.Controls.Add(lbl_edit);
		pnl_sub.Controls.Add(tb);
		pnl_sub.Controls.Add(lbl_br);
		pnl_sub.Controls.Add(img_btn_update_edit);
		pnl_sub.Controls.Add(img_btn_remove);
		pnl_sub.CssClass = "note_sub_panel";

	///fill hover controls with sub panel that will be displayed (3rd fill)
		hvm_note.Controls.Add(pnl_sub);

	///fill 
		ph_your_note.Controls.Add(pnl_date);
		hold_date = check_date;
		i++;

	}
	/// fills 
	 ph_your_note.Controls.Add(pnl_main);

		}

/// THIS IS THE AREA THAT I NEED TO DETERMINE THE VALUE OF THE TEXBOX
/// code in brackets is wrong and is one of my feeble attempts to return the value
protected void img_btn_update_note_Click(object sender, ImageClickEventArgs e)
	{
		notes_cmd = "update";
		string ctrl_name = "tb_note_" + notes_id.ToString();
		if (ctrl_name != String.Empty)
		{
			
		}
		else
		{
		 lbl_create_note.Text = "failed"; 
		}
	 BindNotes();
	}


A screen shot can be provided for viual eference if needed.

Thanks to anyone who can guide me to the answer.

Steve Crochet
Senior Application Developer
Ticketmaster
(and no I can't, I don't even get free tickets)
AnswerRe: C# getting Text Box Value of a DEEPLY nested Control Pin
Christian Graus20-Oct-09 12:58
protectorChristian Graus20-Oct-09 12:58 
GeneralRe: C# getting Text Box Value of a DEEPLY nested Control Pin
Steve Crochet20-Oct-09 13:11
Steve Crochet20-Oct-09 13:11 
GeneralRe: C# getting Text Box Value of a DEEPLY nested Control Pin
Christian Graus20-Oct-09 13:21
protectorChristian Graus20-Oct-09 13:21 
QuestionGridview Checkbox Not Updating on RowCommand Pin
janetb9920-Oct-09 7:29
janetb9920-Oct-09 7:29 
AnswerRe: Gridview Checkbox Not Updating on RowCommand Pin
janetb9920-Oct-09 11:08
janetb9920-Oct-09 11:08 
QuestionASP.NET - Scrollable Panel and Placing ListView in that Pin
Venkat NP20-Oct-09 5:58
Venkat NP20-Oct-09 5:58 
AnswerRe: ASP.NET - Scrollable Panel and Placing ListView in that Pin
Not Active20-Oct-09 8:07
mentorNot Active20-Oct-09 8:07 
Questionstartdate in dropdownlist Pin
m@dhu20-Oct-09 3:49
m@dhu20-Oct-09 3:49 
AnswerRe: startdate in dropdownlist Pin
Abhijit Jana20-Oct-09 4:00
professionalAbhijit Jana20-Oct-09 4:00 
GeneralRe: startdate in dropdownlist Pin
m@dhu20-Oct-09 4:15
m@dhu20-Oct-09 4:15 
GeneralRe: startdate in dropdownlist Pin
Richard MacCutchan20-Oct-09 4:19
mveRichard MacCutchan20-Oct-09 4:19 
GeneralRe: startdate in dropdownlist Pin
Abhijit Jana20-Oct-09 4:44
professionalAbhijit Jana20-Oct-09 4:44 
GeneralRe: startdate in dropdownlist Pin
m@dhu20-Oct-09 19:45
m@dhu20-Oct-09 19:45 
GeneralRe: startdate in dropdownlist Pin
Abhijit Jana20-Oct-09 20:03
professionalAbhijit Jana20-Oct-09 20:03 
GeneralRe: startdate in dropdownlist Pin
Nisha Agrawal20-Oct-09 20:25
Nisha Agrawal20-Oct-09 20:25 
GeneralRe: startdate in dropdownlist Pin
Abhijit Jana20-Oct-09 21:27
professionalAbhijit Jana20-Oct-09 21:27 
GeneralRe: startdate in dropdownlist Pin
Richard MacCutchan21-Oct-09 0:13
mveRichard MacCutchan21-Oct-09 0:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.