AJAX :: Dynamically Creating Accordions At Runtime
Jan 21, 2011
Newbie in using AJAX . Programming in C# and using SQL as a database. Here is my scenario. User selects a project and I want to display the subprojects related to that project. Here is the query I use to retrieve subprojects.
"SELECT SubProjectName,StartDate,Description FROM SubProject WHERE ProjectName'"+ddlProjectName.text+"';
Currently I store the results of the query in a Dataset. I want to get the SubProjectName in the Header of the Accordion and StartDate and Description values to the text box for each accordion. ( This is what I need to do in each accordian for each subproject)
<asp:AccordionPane ID="AccordionPane2" runat="server">
<Header>
<a href="" onclick="return false;" class="accordionLink">SubProject 1</a>
</Header>
<Content>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="td_left" colspan="2">
<asp:Label ID="Label1" runat="server" Text="Start Date"></asp:Label>
</td>
<td class="td_left" colspan="2">
<asp:TextBox ID="StartDate" runat="server"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td_left" colspan="2">
<asp:Label ID="Label2" runat="server" Text="Description"></asp:Label>
</td>
<td class="td_left" colspan="2">
<asp:TextBox ID="txtDecription" runat="server"></asp:TextBox>
</td>
</tr>
</table>
</Content>
</asp:AccordionPane>
How can I do this? Some code example would be great on how to creat the accordinas ,text boxes dynamically and fill the values.
View 1 Replies
Similar Messages:
Aug 5, 2010
I have a requirement whereby one or more image buttons need to be created in a user control at runtime. The number of buttons is determined from a database where a user can add one or more rows that contain an image for each button, so if a user adds 3 images to a table, 3 image buttons are created. Ive used this code but I get an error at runtime
The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.
[Code]....
this is the usercontrol aspx
[Code]....
I basically want one or more buttons to render within the div in the usercontrol. Ive only got the code written for one button at the moment while I test the rendering, eventually they will be rendered in a loop of records taken from a database. Whats the best way to do this ?
View 2 Replies
Aug 6, 2010
I've an item template inside a grid which has a <asp:LinkButton/> inside it. I assign the text for the link button as
<%# Convert.ToString(Eval("Tags"))%>
Tags can have a string with multiple tags in it delimited by space. For eg. "sports", "sports cricket", "sports cricket sachin" are the examples of some possible tags.
I want to create a button for each tag inside the string. How can i create the controls (server control - linkbutton) dynamically during runtime inside the grid item template?
View 2 Replies
Aug 5, 2010
implementing accordions vertically and horizontally using asp.net and ajax..
View 1 Replies
Feb 25, 2010
I have a GridView with a column of checkboxes. I also have a panel pnlSubmitOffer which serves as a modal dialog with ajaxToolkit:ModalPopupExtender:
[Code]....
I need a set of controls (text boxes and datetimepickers) to appear on the modal dialog based on how many checkboxes in the GridView are checked, i.e. a set for each checked record. Thus the controls should be added to the panel dynamically. But I don't know how to do it, as btnSubmitOffer click is not handled, because the modal dialog appears first. I was told that the controls can be added dynamically using javascript, but my knowledge of it is not enough.
View 2 Replies
Jan 22, 2010
i'm creating dynamically an AnimationExtender using a RenderPanel but when i run my app, it catch this error:
Translated:
"The TargetControlID it's not valid. It can't find any Control with the control's identificator "Tipo0""
Original:
"El TargetControlID de 'extTipo0' no es válido. No se pudo encontrar ningún control con el id. 'Tipo0'."
This is the code where i create the objets:
int IdLinea = 0;
LinkButton TipoHito = new LinkButton();
Hito.TipoHito = TipoHito;
TipoHito.ID = "Tipo" + IdLinea;
TipoHito.Text = DRHito.Tipo;
TipoHito.ToolTip = "VER MAS INFORMACIÓN DEL HITO";
TipoHito.OnClientClick="return false;";
[Code]...
View 2 Replies
Jan 6, 2011
I created a table dynamically with its row cell contain textbox. Now I need to show a hovermenuextender popup window on each rows textbox. I spend more time for this. But not getting till now.
This is my code for dynamically created table
private void GenerateTable(int colsCount, int rowsCount) {
string qry2 = "select lchannelname,ltransformdata from latestchannel where lenable=1";
DataTable dt = ob.getDetails(qry2);
dt.Columns.Add(new DataColumn("combined", System.Type.GetType("System.String"),
"lchannelname+ ' '+ltransformdata"));
//Create the Table and Add it to the Page
Table table = new Table(); table.ID = "Table1";
Page.Form.Controls.Add(table); int flag=0;
foreach (DataRow dr in dt.Rows) { TableRow row = new TableRow(); row.Width = 200;
TableCell cell = new TableCell(); TextBox tb = new TextBox();
tb.BorderColor = System.Drawing.Color.OliveDrab;
cell.BorderColor = System.Drawing.Color.OliveDrab;
cell.BorderWidth = 1; cell.Width = 200; tb.Width = 200;
// tb.ReadOnly = true; tb.Text = dr["combined"].ToString();
tb.ID =flag.ToString(); cell.Controls.Add(tb);
row.Cells.Add(cell); table.Rows.Add(row);
AjaxControlToolkit.HoverMenuExtender hrv = new AjaxControlToolkit.HoverMenuExtender(); hrv.TargetControlID = tb.ID;
Here I am confusing for which way is using for popup panel1
hrv.PopupControlID = Panel1.ID;
hrv.PopupPosition = AjaxControlToolkit.HoverMenuPopupPosition.Right;
Panel1.Controls.Add(hrv); flag++; } }
protected void Page_Load(object sender, EventArgs e) {
int numOfColumns = 1;
int numOfRows = ob.selectLatestEnableCount();
GenerateTable(numOfColumns, numOfRows); }
I want to popup this Panel1 on textbox through hovermenuextender
<asp:Panel ID="Panel1" runat="server" Height="50px" Width="125px">
<div style="border:1px outset white;padding:2px;">
<div><asp:ImageButton ID="ImageButton1" ImageUrl="~/images/close.png" runat="server" /> <asp:LinkButton ID="lnkButtonHide" runat="server" CommandName="Edit" Text="Hide Channel" ForeColor="olivedrab" OnClick="lnkButtonHide_Click1" /> </div>
<div> <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/element_up.png" /> <asp:LinkButton ID="LinkButtonUp" runat="server" CommandName="Cancel" Text="Go Up One Pos" ForeColor="olivedrab" OnClick="LinkButtonUp_Click2"/> </div>
<div> <asp:ImageButton ID="ImageButton3" runat="server" ImageUrl="~/images/element_down.png" /><asp:LinkButton ID="lnkButtonDown" runat="server" CommandName="Delete" Text="Go Down One Pos" ForeColor="olivedrab" OnClick="lnkButtonDown_Click1"/> </div> </div> </asp:Panel>
View 1 Replies
Sep 11, 2010
Here is what I have done so far. I have a datalist to show notifications. The datalist is bound to an sqldatasource.
I have tried to use a collapsible panel extender in the datalist to hide or show message, but the designer could not render the datalist because of the collapsible panel control. It gives an error "Unknown server tag asp:CollapsiblePanelExtender"
here is my code
[Code]....
View 4 Replies
Jan 23, 2010
1. On OnCreatedUser event, I create a folder for each members, so that they can store their files inside those. The thing is I use User.Provider key as a folder name. Is this a good way to store? Is this OK from security view point. Otherwise I am planning to use the User.Username. Here are the codes inside the OnCreatedUser event.
[Code]....
2. Inside these user folders I want to put web.config at run time [at the time of registration]. So that a member cannot access files of other members at any cost. Do you have any idea on creating web.config file at runtime inside these folders? Else if you can provide me any other options, I am eager to listen that. I don't want to call database frequently. So if there is any easy solution.
View 3 Replies
Mar 31, 2011
I've an ASP.NET MVC web site and I'm using AspNetSqlProvider to configure Secutiry
So, I runned aspnet_regsql command to create and configure aspnetdb database that hold users, roles , etc....
I use the asp.net application web management to create roles, users , etc... Ok
But I would like to create roles at runtime :
- If a new user visit my application, I would like to register it as a user and affect it a role ( Visitors)
- If a seller N visit my application, I would like to create a role ( seller N) to register the vositor as admin of seller N
How can we manager this scenario using my configured database aspnetdb ?
View 1 Replies
Jan 14, 2011
I have a DataTable where the columns are generated programmatically at runtime. I then bind this DataTable to a GridView. What I'm wondering is how I can create the GridView to accommodate this, and if it's not possible, how I can output the DataTable into nicely formatted HTML.
View 3 Replies
Jul 14, 2010
I have a Masterpage that has Treeview. You can select some nodes there. Based on the selection you get some items in the Default.aspx's Placeholder, you get a image and a linkbutton placed in a Panel. Like this :
This code is in the Default.aspx that has the Masterpage.
[Code]....
There seems to be problem when i create the controllers at runtime, when the site does a postback, lets say if i click "Enska" in the treeview i get the results in the image above. Lets say that i then click "The Punk Panther" i get a error.
An error has occurred because a control with id 'ctl00$CPH_Main$ctl05' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.
Also, how would i go by making a event handler for the linkbutton at runtime, can i make one event handler that every linkbutton uses or what ? I want the folder and the linkbutton to be clickable and link to the same place, is it simpler to make the whole Panel clickable, if so, how would i get a "OnClick" event on it ?
View 1 Replies
Jan 9, 2010
I need to create aspx pages on the fly or at the runtime.I read that creating a template page and posting content to the page would be a solution, in a few posts in the forum. Can i get information on this method.
View 5 Replies
Mar 1, 2011
I want to create several instances of a webcontrol on my web page each time the user clicks an 'add' button.
HTML
[Code]....
c#
[Code]....
View 7 Replies
Jan 30, 2010
Sometimes MS provides error message so silly that its hard to understnad and you feel like throwing away all things.
My Web.Config does not contain any entries of MemberShip, Role or Profile.
I want to create a membership provider dynamically through code at runtime. I wrote following code and it receives following error message. I don;t know how come machine.config error appears in my application. how annoying.
Parser Error Message: The connection name 'LocalSqlServer' was not found in the applications configuration or the connection string is empty.
Source Error:
[Code]....
Source File: C:WindowsMicrosoft.NETFrameworkv2.0.50727Configmachine.config Line: 139
Following is the CODE.
[Code]....
View 22 Replies
Aug 4, 2010
i am creating some of the control at runtime according database values. problem is that when i click onto the button, if the text box is empty, the required field validator(genrated at runtime) show first time that the text box is empty. but one agin i click on to the button, it doest show any error messege and all of the control which i am genrating at run time are hiding when i see at the page source, no control is find there.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using AjaxControlToolkit;
using click2install.controls;
public partial class FeebackForm_Client : System.Web.UI.Page
{
HtmlGenericControl table = new HtmlGenericControl("table");
DataSet ds = new DataSet();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
CreateForm();
}
}
public void CreateForm()
{
ds = DBManager.ExecuteDataset("[FeedBack_FeedbackDetail_get]");
for (int i = 1; i < ds.Tables[0].Columns.Count - 1; i = i + 4)
{
//CreateControl(txtAddress.Text.ToString(), txtAddressRun, false, false, txtAddressToolTip.Text, txtAddressWaterMark.Text);
string Name = ds.Tables[0].Rows[0][i].ToString().Replace(" ","");
if (Name != "")
{
TextBox txtControl = new TextBox();
//RequiredTextBox txtControl = new RequiredTextBox();
txtControl.ID = "txt" + Name;
txtControl.CausesValidation = true;
bool RequiredField;
bool ToolTip;
if (ds.Tables[0].Rows[0][i + 3].ToString() == "True")
{
RequiredField = true;
}
else
RequiredField = false;
if (ds.Tables[0].Rows[0][i + 1].ToString() != "")
{
ToolTip = true;
}
else
ToolTip = false;
string TooltipText = ds.Tables[0].Rows[0][i + 1].ToString();
string WaterMarkText = ds.Tables[0].Rows[0][i + 2].ToString();
CreateControl(Name, txtControl, RequiredField, ToolTip, TooltipText, WaterMarkText);
}
}
HtmlGenericControl tr = new HtmlGenericControl("tr");
HtmlGenericControl td1 = new HtmlGenericControl("td");
HtmlGenericControl td2 = new HtmlGenericControl("td");
HtmlGenericControl td3 = new HtmlGenericControl("td");
HtmlGenericControl td4 = new HtmlGenericControl("td");
Button btnInsertRun = new Button();
btnInsertRun.Text = btnSubmit.Text.ToString();
btnInsertRun.ValidationGroup = "Check";
td2.Controls.Add(btnInsertRun);
tr.Controls.Add(td1);
tr.Controls.Add(td2);
tr.Controls.Add(td3);
tr.Controls.Add(td4);
table.Controls.Add(tr);
pnlPreview.Controls.Add(table);
System.Threading.Thread.Sleep(500);
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "Hide();", true);
System.Threading.Thread.Sleep(500);
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), "ShowAddDisability()", true);
}
public void btnInsertRun_Click(object sender, System.EventArgs e)
{
CreateForm();
//ds = DBManager.ExecuteDataset("[FeedBack_FeedbackDetail_get]");
//TextBox txt1,txt2,txt3,txt4,txt5=new TextBox();
//objBox2 = this.Page.FindControl("objBox2") as TextBox;
string ss = "txt" + ds.Tables[0].Rows[0][1].ToString();
//TextBox objTextBox = (TextBox)PnlControlPanel1.FindControl(strControlName);
TextBox txt1 = new TextBox();
txt1 = (TextBox)this.Page.FindControl("txt" + ds.Tables[0].Rows[0][1].ToString());
//txt1=this.pnlContainer.FindControl("txt"+ds.Tables[0].Rows[0][1].ToString()) as TextBox;
// txt2 = this.pnlContainer.FindControl("txt" + ds.Tables[0].Rows[0][5].ToString()) as TextBox;
// txt3 = this.pnlContainer.FindControl("txt" + ds.Tables[0].Rows[0][9].ToString()) as TextBox;
// txt4 = this.pnlContainer.FindControl("txt" + ds.Tables[0].Rows[0][13].ToString()) as TextBox;
// txt5 = this.pnlContainer.FindControl("txt" + ds.Tables[0].Rows[0][17].ToString()) as TextBox;
string fh = txt1.Text;
//DBManager.ExecuteNonQuery("Feedback_FeedbackInsert", ds.Tables[0].Rows[0][1].ToString(), txt1.Text,ds.Tables[0].Rows[0][5].ToString(), txt2.Text,ds.Tables[0].Rows[0][9].ToString(), txt3.Text,ds.Tables[0].Rows[0][13].ToString(), txt4.Text,ds.Tables[0].Rows[0][17].ToString(),
txt5.Text);
Response.Write("Ho Gya");
}
public void CreateControl(string Name, TextBox ControlID, bool RequiredField, bool Tooltip, string TooltipText, string WaterMarkText)
{
if (WaterMarkText == "")
WaterMarkText = Name;
HtmlGenericControl tr = new HtmlGenericControl("tr");
HtmlGenericControl td1 = new HtmlGenericControl("td");
HtmlGenericControl td2 = new HtmlGenericControl("td");
HtmlGenericControl td3 = new HtmlGenericControl("td");
HtmlGenericControl td4 = new HtmlGenericControl("td");
td1.InnerText = Name;
ControlID.ValidationGroup = "Check";
//ControlID.ValidatorMessage = Name + " is Required Field";
//ControlID.ValidatorDisplayType = ValidatorDisplay.Dynamic;
//ControlID.ValidatorEnableClientScript = true;
td2.Controls.Add(ControlID);
if (RequiredField == true)
{
//RequiredFieldValidator Valid = new RequiredFieldValidator();
//Valid.ID = "Valid" + Name;
//Valid.ControlToValidate = ControlID.ID.ToString();
//Valid.ErrorMessage = Name + " is Required Field";
//Valid.Text = "*";
//Valid.Display = ValidatorDisplay.Dynamic;
//Valid.EnableViewState = true;
//Valid.SetFocusOnError = true;
//Valid.Enabled = true;
//Valid.EnableClientScript = true;
//Valid.InitialValue = WaterMarkText;
//Valid.ValidationGroup = "Check";
//td3.Controls.Add(Valid);
}
if (Tooltip == true)
{
HtmlGenericControl span = new HtmlGenericControl("span");
//span.Attributes.Add("class", "hotspot");
span.Attributes.Add("onmouseout", "tooltip.hide();");
span.Attributes.Add("onmouseover", "tooltip.show('" + TooltipText + "');");
HtmlImage img = new HtmlImage();
img.Src = "info.png";
span.Controls.Add(img);
td4.Controls.Add(span);
}
//TextBoxWatermarkExtender WaterMark = new TextBoxWatermarkExtender();
//WaterMark.WatermarkText = WaterMarkText;
//WaterMark.EnableClientState = true;
//WaterMark.TargetControlID = ControlID.ID.ToString();
//WaterMark.Enabled = true;
//WaterMark.ID = "WaterMark" + Name;
//td1.Controls.Add(WaterMark);
tr.Controls.Add(td1);
tr.Controls.Add(td2);
tr.Controls.Add(td3);
tr.Controls.Add(td4);
table.Controls.Add(tr);
}
}
after rendring the page...
<div id="pnlContainer">
<table><tbody><tr><td>Email</td><td><input type="text" id="txtEmail" name="txtEmail"></td><td></td><td><span onmouseover="tooltip.show('Email');" onmouseout="tooltip.hide();"><img src="info.png"></span></td></tr><tr><td>FirstName</td><td><input type="text"
id="txtFirstName" name="txtFirstName"></td><td></td><td><span onmouseover="tooltip.show('First Name');" onmouseout="tooltip.hide();"><img src="info.png"></span></td></tr><tr><td>LastName</td><td><input type="text" id="txtLastName" name="txtLastName"></td><td></td><td><span
onmouseover="tooltip.show('Last Name');" onmouseout="tooltip.hide();"><img src="info.png"></span></td></tr><tr><td>City</td><td><input type="text" id="txtCity" name="txtCity"></td><td></td><td><span onmouseover="tooltip.show('City');" onmouseout="tooltip.hide();"><img
src="info.png"></span></td></tr><tr><td>Address</td><td><input type="text" id="txtAddress" name="txtAddress"></td><td></td><td><span onmouseover="tooltip.show('Address');" onmouseout="tooltip.hide();"><img src="info.png"></span></td></tr></tbody></table></div>
but after the click on to the button it shows only the container div..
<div id="pnlContainer"></div>
View 4 Replies
Mar 7, 2011
I want to create buttons and text boxs runtime and assigne to asp table.
When user clicks on button text box should be visible and user will be able to type some text and submit to server. This is nothing but something
like Blog. I am able to create asp table, button and testboxes but could not do visibility and events of buttons.
View 2 Replies
Nov 24, 2010
I'm having problems binding controls at runtime. I've some user controls which need to be bind to the page when one of the dropdownlist selected index changed.
I can able to bind them properly but when if there is any postback event happens I am losing the controls and control values which were created runtime.
How do I avoid binding them again and again.
View 3 Replies
Jan 17, 2010
suppose that i have a gridview and an objectdatasource in my webform
with that i want to include several search criteria
the problem is that i want theme dynamic
for example
i have a dropdownlit with customers list
the first item in the dropdownlist is "All customers" for example
if i select it no "customer select parameter" is created
otherwise i have a "customer select parameter" for the objectdatasource and it's value is the dropdownlist.selectedvalue
View 2 Replies
Jan 20, 2011
I am developing an application using ASP.Net MVC 2. I have different modules and every module have different styles. My design goal is to use single master page and assign CSS at runtime based on the module selected by the user.
View 4 Replies
Mar 17, 2011
I have created a gridview which adds a remove button through item template. I wish to know how do u remove the row from grid view dynamically depending upon the button he clicks ?
protected void RemoveBtn_OnClick(object sender, EventArgs e)
{
Button clickedButton = sender as Button;
GridViewRow row = (GridViewRow)clickedButton.Parent.Parent;
int rowID = Convert.ToInt16(row.RowIndex);
GridView1.DeleteRow(rowID);
}
[code]...
View 1 Replies
Nov 24, 2010
I have been trying to add validation attributes dynamically at runtime and all works ok. I next tried to add a DisplayAttribute at runtime hooking into the same
[Code]....
View 10 Replies
Mar 31, 2011
I want to create a mailto anchor tag at runtime. Is this possible? I've tried this:
[Code]....
Neither of these worked. I tried adding the "mailto:" in front of the {0}, but this just became part of the perceived URL. I read a post online about using data attributes to add the value as a property of a class, but I can't do that, as I'm stuck using .NET 3.5 for this project. I honestly didn't think this was going to be such a big deal. I just want to populate the email address of the anchor tag with a variable value.
View 2 Replies
May 24, 2010
I have a web user control with dynamic LinkButton think an event in which you assign events to them (LinkButton.Click + = new EventHandler (Method)).The problem is that these events do not run, I did test creating and if you run statically.Why is it??I need to be created dynamically at runtime.For Examples :
for (int i = 0; i <= 5; i++)
{
Button boton = new Button();
[code]...
View 3 Replies
Jun 24, 2010
i have one input text box. if i input 4 into that input text box i need to generate 4 text boxes at run time.
View 7 Replies