|
Are your TextBoxes immediate descendants of the page? It's unlikely; you've probably got several layers of controls between them.
Try this:
public void ClearTextBoxes(Control control)
{
foreach (Control c in control.Controls)
{
var textBox = c as TextBox;
if (textBox != null)
{
textBox.Text = " ";
}
else if (c.HasControls)
{
ClearTextBoxes(c);
}
}
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
try this code
protected void Button1_Click(object sender, EventArgs e)
{
ClearTextBoxes(Page.Controls);
}
void ClearTextBoxes(ControlCollection control)
{
foreach (Control ctrl in control)
{
if (ctrl is TextBox)
((TextBox)ctrl).Text = string.Empty;
ClearInputs(ctrl.Controls);
}
}
|
|
|
|
|
|
|
#region Clear all text boxes page value (for server-side controls)
///
/// ex:FindTextBox(this);
///
/// <param name="c" />
public void FindTextBox(Control c)
{
if (c.Controls != null)
{
foreach (Control x in c.Controls)
{
if (x is System.Web.UI.WebControls.TextBox)
{
((System.Web.UI.WebControls.TextBox)x).Text = string.Empty;
}
FindTextBox(x);
}
}
}
#endregion
#region Clear all text boxes page value (for client side controls)
///
/// ex:FindHtmlInputText(this);
///
/// <param name="c" />
public void FindHtmlInputText(Control c)
{
if (c.Controls != null)
{
foreach (Control x in c.Controls)
{
if (x is System.Web.UI.HtmlControls.HtmlInputText)
{
((System.Web.UI.HtmlControls.HtmlInputText) x).Value = string.Empty;
}
if (x is System.Web.UI.HtmlControls.HtmlTextArea)
{
((System.Web.UI.HtmlControls.HtmlTextArea)x).Value = string.Empty;
}
FindHtmlInputText(x);
}
}
}
#endregion
ex:FindHtmlInputText(this);
Hope you can help!!!
|
|
|
|
|
I Want To Validate my Windows Project while User can not Share this project to another or in One year Project will be Expired
Like An Antivirus Program Expired after One or two months
|
|
|
|
|
I would suggest you to google like this: "implementing licensing for trial versions in windows applications"
Be a good professional who shares programming secrets with others.
|
|
|
|
|
First off, this is the ASP.Net forum and not the Windows Application forum. Secondly, you need to implement a license. There are many, many ways to do it. Some are easier but not as resistant to hacking and others are more complex to implement. You may want to research online the various options and then decide what works best for you.
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
Sorry But can u Suggests me some Ways to do that
|
|
|
|
|
.NET Reactor[^] is a powerful .NET Code Protection & Software Licensing System. Protect, encrypt, obfuscate, merge and license your .NET assemblies.
Maulik Dusara
Sr. Sofware Engineer
|
|
|
|
|
I Have Downloaded . net Reactor.. but it working.. i think it is very difficult to use.. can you suggest me how can i use .Reactor to make a License Project.
|
|
|
|
|
hi,
can anyone suggest me the best book for mvc4 pls
|
|
|
|
|
http://it-ebooks.info/book/1617/
try this link to download the book on mvc4
|
|
|
|
|
|
|
Ok this has sort of been asked before but also somewhat differently here. I have a regular drop down (not connected to a database) that just has the topics of subjects.
This is a sample of what I have:
<asp:DropDownList id="ddlcourseType" runat="server"
onselectedindexchanged="ddlcourseType_SelectedIndexChanged"
AutoPostBack="True">
<asp:ListItem Value="None">Please Select</asp:ListItem>
<asp:ListItem Value="Engl">English</asp:ListItem>
<asp:ListItem Value="Math">Math</asp:ListItem>
<asp:ListItem Value="Soci">Social Studies</asp:ListItem>
<asp:ListItem Value="Scie">Science</asp:ListItem>
<asp:ListItem Value="Hist">History</asp:ListItem>
</asp:DropDownList>
I want to make it so that when it changes the next part will search and select teachers that teach that specific subject. I am using an Access Database for connection.
I have pieced together some of what others did in an attempt to get it to work but no.
protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
{
OleDbConnection dbConn = null;
OleDbCommand dbCmd;
OleDbDataReader dr;
String strConnection;
String strSQL;
string path = Server.MapPath("eAcademy_DB.mdb");
string Teachable = Convert.ToString(ddlcourseType.SelectedValue);
strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
dbConn = new OleDbConnection(strConnection);
dbConn.Open();
strSQL = "select * from tblEmployee where canTeach=" + Teachable;
dbCmd = new OleDbCommand(strSQL, dbConn);
DataSet ds = new DataSet();
dbConn.Close();
ddlTeacher.DataSource = ds;
ddlTeacher.DataTextField = "emp_ID";
ddlTeacher.DataValueField = "emp_ID";
ddlTeacher.DataBind();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
if (ddlTeacher.SelectedValue == "0")
{
ddlTeacher.Items.Clear();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
}
I think what I really need to do is make a for loop and have it iterate for the amount of teachers that are in the list, and then have it populate the list, but not sure how exactly to do this.
It is hanging up on the ds part each time. I know the databind is causing it so this is why I thought perhaps better to iterate this? Any help would be appreciated.
The values from the first list are in the tblEmployee for "T" Teachers that can teach those classes. So that is why I want to 2nd drop down populated with their names. Thanks!
|
|
|
|
|
WickedFooker wrote: strSQL = "select * from tblEmployee where canTeach=" + Teachable;
Your first problem is SQL Injection[^]. Never use string concatenation to insert parameters into a query; use a parameterized query instead.
WickedFooker wrote: dbCmd = new OleDbCommand(strSQL, dbConn);
DataSet ds = new DataSet();
dbConn.Close();
Creating an OleDbCommand object isn't going to execute the query, let alone store the results in another variable. You could use ExecuteReader , iterate through the results, and add them to a DataTable , but it's much simpler to use a DataAdapter to do the work for you.
WickedFooker wrote: if (ddlTeacher.SelectedValue == "0")
{
ddlTeacher.Items.Clear();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
Since you've just inserted an item with a value of "0" as the first item, this will most likely be the selected item. Even if your data-binding was working, this block of code will most likely throw away the results from the database and leave you with an empty list.
Try something like this:
protected void ddlcourseType_SelectedIndexChanged(object sender, EventArgs e)
{
string path = Server.MapPath("eAcademy_DB.mdb");
string connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + path;
string commandText = "SELECT * FROM tblEmployee WHERE canTeach = ?";
var ds = new DataSet();
using (var connection = new OleDbConnection(connectionString))
using (var command = new OleDbCommand(commandText, connection))
{
command.Parameters.AddWithValue("@p0", ddlcourseType.SelectedValue);
var adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
}
ddlTeacher.DataSource = ds;
ddlTeacher.DataTextField = "emp_ID";
ddlTeacher.DataValueField = "emp_ID";
ddlTeacher.DataBind();
ddlTeacher.Items.Insert(0, new ListItem("--Select--", "0"));
}
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I just want to thank you for the help! This did the trick. I was able to populate the 2nd table with perhaps the smallest of changes.
string commandText = "SELECT * FROM tblEmployee WHERE canTeach = " + ddlcourseType.SelectedValue;
I removed the select on the bottom and instead put it in the page load since it is more needed for looks when the page loads. Thanks again for your help. I am certain I will be back for more
REVISED: I see your warning about String concatenation. I will change it back. I went back to the way you originally posted it!
modified 20-May-13 16:56pm.
|
|
|
|
|
i think you are missin to fill your dataset your command object not executing use
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(dbCmd)
adapter.Fill(ds);
after
dbCmd = new OleDbCommand(strSQL, dbConn);
then it fill dataset and your debug will show your dataset contain value.
|
|
|
|
|
Hi All,
I have an asp.net application in which I am using two tables, Table1 and Table1Staging. Staging table data is updated every month.
And both have the same columns except the identity columns for the two tables are different. The reason for that is Table1 is transactional table so that we have to use an Identity columnfor that, here we are doing it with Unique Identifier. And there is an identity column in Staging table as auto increment integer for the sake of Entity Framework.
They both have a unique contraint column called clientId on which I am going to write all the logic to update or modify.
Now my question is I want to get all the rows in the staging table whose clientid exists in staging table but doesnt exist in transactional table, similar to not in operator in SQL Query.
Please if somebody can help me that would be really helpfull. I am searching from my side also. But if someone can help me its really great.
Thanks in advance.
Thanks & Regards,
Abdul Aleem Mohammad
St Louis MO - USA
modified 17-May-13 17:44pm.
|
|
|
|
|
See here[^]. Couldn't you call a stored procedure or even a view to do the heavy lifting?
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
Those who seek perfection will only find imperfection
nils illegitimus carborundum
me, me, me
me, in pictures
|
|
|
|
|
Hi @all
I´m new to Expressiontrees and their invocation...
but they seem to be really mighty and useful...
I know that one can extend expressiontrees, but up until now I wasn´t been able to fully comprehend how to do that..
practically I want to "convert" this lambda into an expressiontree:
(o => o.LognName == name)
and I do that by this
Expression<Func<Users_UserAccount, bool>> whereLogonName = LinqExtender.DynamicLinq.BuildOrTree<Users_UserAccount, string>(LogonName, UserAccount => UserAccount.LogonName);
so far so good. I also know that I now can query multiple users... fine thing...
what´s really cool about this is, that expressiontree returns whatever you need takes any type of parameter... a fine thing would be if I was able to pass the correct "sql/linq" query to it...
to be honestly, my desire goes for this:
(o => o.LognName == name && o.LogonPW == "12345")
now my question is:
how to link different params in an expressiontree?
I heard about
Expression.Or
Expression.And
and am using it, but I feel that this does not function properly and as desired...
here´s my function of the treebuild:
public static Expression<Func<TValue, bool>> BuildOrTree<TValue, TCompareAgainst>(
IEnumerable<TCompareAgainst> wantedItems,
Expression<Func<TValue, TCompareAgainst>> convertBetweenTypes)
{
ParameterExpression inputParam = convertBetweenTypes.Parameters[0];
Expression binaryExpressionTree = BuildBinaryOrTree(wantedItems.GetEnumerator(), convertBetweenTypes.Body, null);
return Expression.Lambda<Func<TValue, bool>>(binaryExpressionTree, new[] { inputParam });
}
I've found that on the interwebs...it´s NOT mine...but with very few changes, I've also implemented the AND-equivalent. whoa... what an effort...
so, to put long things short:
how to combine the both of them to achieve the desired query?
thanks in advance!
what a cool community
[edit]
forgot that:
private static Expression BuildBinaryOrTree<T>(
IEnumerator<T> itemEnumerator,
Expression expressionToCompareTo,
Expression expression)
{
if (itemEnumerator.MoveNext() == false)
return expression;
ConstantExpression constant = Expression.Constant(itemEnumerator.Current, typeof(T));
BinaryExpression comparison = Expression.Equal(expressionToCompareTo, constant);
BinaryExpression newExpression;
if (expression == null)
newExpression = comparison;
else
newExpression = Expression.OrElse(expression, comparison);
return BuildBinaryOrTree(itemEnumerator, expressionToCompareTo, newExpression);
}
sorry
ps:hopefully I dove into the correct forum...
aaargh, ultraedit:
addendum:
LogonName in the lambda was of type string, the Expressionparam is of type string[]
addendum 458:
as one might suspect:my math knowledge is not that sophisticated... the term binarytree is familiar to me since 4 days or 5...
but, i´m somewhat able to use it...
just like luke skywalker and his lasersword...
he is capable to use it as a weapon, but is he able to assemble it!?
modified 17-May-13 9:25am.
|
|
|
|
|
once more I´ve forgotten something...namely the calling of that expression:
Expression<Func<Users_UserAccount, bool>> whereLogonName = LinqExtender.DynamicLinq.BuildOrTree<Users_UserAccount, string>(LogonName, Users_Users => Users_Users.LogonName);
Expression<Func<Users_UserAccount, bool>> whereLogonPW = LinqExtender.DynamicLinq.BuildAndTree<Users_UserAccount, int>(siteparam, Users_Users => Users_Users.LogonPW);
Users_UserAccount medProOrignal = ce.Users_UserAccount.Where(whereLogonName).Where(whereLogonPW ).First();
but I found out, that there´s a 'priority-problem', when using .First();
but that´s so obvious...
consider the following:
two users:
user a:
UID:1 logonname: gargamel PW: a
user b:
UID:2 logonname: gargamel PW: b
actually I've overseen the fact that I was using .First()
.First() will simply take UID1 becoz it´s the first one found...
now I've tried it with .Single() and it returns the desired user...
but what left me dumb is the fact, that I can´t see the way this query get´s prioritized in terms of params...
actually, I hope my question is considerably clear and that I forgot nothing...
[eeedit]
I "profiled" it in SQLM MGMT Profiler but i´m veeery weak in SQL... no clue at all..
modified 17-May-13 9:21am.
|
|
|
|
|
Hi,
I have seen in some website they use different fonts than the standard. For example:
.yakoutb
{
font-family: 'Yakout W20 Bold';
}
How can I do this?
Technology News @ www.JassimRahma.com
|
|
|
|
|