Isaac Johnson
asked on
How to reference asp tag that is in a variable?
Can you reference a asp tag that is passed in variable. I have a table that contains rows which
contain asp id's example aspTagName = txtFirstName, fielRequired = false
I want to look at the column fieldRequired and based on value of false
remove the attribute required from the asp page using the value of
the aspTagName(txtFirstName)
Please advise.
Thanks in advance
contain asp id's example aspTagName = txtFirstName, fielRequired = false
I want to look at the column fieldRequired and based on value of false
remove the attribute required from the asp page using the value of
the aspTagName(txtFirstName)
Please advise.
Thanks in advance
ASKER
<input name="myText" type="text" id="myText" required="required">
The code is a sample.
I will receive the value of the id from a table which I will store in a variable.
I want to use the variable to match the id(find control) so I can remove required attribute.
ASKER
Complete code to date trying to find answer before expansion using sql etc..
I have tried many variations, but can't find the answer.
Need help for project started last Thursday.
I have tried many variations, but can't find the answer.
Need help for project started last Thursday.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
//using System.Windows.Forms;
namespace WebApplication2
{
public partial class index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string straspID = "myText";
bool fieldRequired = false;
if (fieldRequired == false)
{
//FindControl("myText");
FindControl(straspID);
myText.Attributes.Remove("required"); // I want to use variable here straspID
}
}
}
}
[/code
[code]
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebApplication2.index" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="myText" runat="server" required="required"></asp:TextBox>
</div>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for your assistance.
now on the right, do a right click on that table tag and choose "copy Outer HTML" and post it here