|
If you know the parent of the control, you can use the FindControl method to locate the control.
---
b { font-weight: normal; }
|
|
|
|
|
If you can't use findparent, you could use reflection [assuming you are working in code behind]:
public void foo()
{
string TextBoxName ="txtBar";
TextBox requiredBox = GetBoxByName(TextBoxName);
requiredBox.Text = "New Value";
}
protected TextBox GetBoxByName(string name)
{
Type t = this.GetType();
FieldInfo fi = t.GetField(name);
return fi.GetValue(this) as TextBox;
}
I've not tested this properly, so don't be surprised if it doesn't work. If you want to specify which property you want (in your example .Text) you could create a GetProperty method running along the lines of "GetBoxByName" which uses reflection to find the property you want.
|
|
|
|
|
hi
i have an array which contain some values .i want to pass this array to javascript function from codebehind file.How to do this?
thanks
vijay
|
|
|
|
|
You can't do that.
What you can do is to create Javascript code that will recreate the array. For an example an array of integers:
int[] values = new int[] { 1, 2, 3, 4 };
StringBuilder code = new StringBuilder();
bool first = true;
foreach (int v in values) {
code.Append(first ? "var values = [" : ", ");
first = false;
code.Append(v);
}
code.Append("];");
Page.ClientScript.RegisterStartupScript(this.GetType(), "ValuesArray", code.ToString(), true);
---
b { font-weight: normal; }
|
|
|
|
|
i would like to pop out a message box when the user click the delete button to ensure the user really want to delete the data, when i put the code messagebox.show(xxxxx), it cannot run, is it want to import any namespace for it ?
thanks.
Best regards,
Chee ken
|
|
|
|
|
You can use javascript confirm for the same purpose.
Best Regards,
Apurva Kaushal
|
|
|
|
|
How to write the javascript ? and i search from msdn, the sample of the messagebox is like messagebox.show() , why my web cannot run ? i so blur. Hope you can answer me , thanks !
Best regards,
Chee ken
|
|
|
|
|
Actually when a user clicks on the delete button, it is not at all required to go to the server and show the confirmation message. Inspite you can use javascript for that it will remain there in client side only. And suresh has given the complete sample code for that.
Best Regards,
Apurva Kaushal
|
|
|
|
|
function confirm_delete()
{
if ( confirm( "Are you sure you want to delete the Record?") == true )
return true;
else
return false;
}
try this javascript in ur html view code
and
write this code in ur itemcreated event of grid
try
{
if ( e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem )
{
_myButton.Attributes.Add("onclick", "return confirm_delete();");
}
}
regards,
suresh
suresh babu.k
|
|
|
|
|
Your message box - it might appear on your web server...
|
|
|
|
|
You are correct in sense that the code is executed on the server, so if a message box would appear, it would appear on the server.
The ASP.NET environment is specified as not having any user interface, though, so an attempt to display a message box will cause an exception.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for all helping me, i know how to do it already. ;)
Best regards,
Chee ken
|
|
|
|
|
Kindly let me the easiest way of learning ASP.NET
|
|
|
|
|
Get some books and start reading that. Also practice(write code) a lot.
Best Regards,
Apurva Kaushal
|
|
|
|
|
Kindly suggest some good books.
Regards
Dev Brar
|
|
|
|
|
You can check these books they are really good:
Pro ASP.NET 2.0 in C# 2005 from Apress
Programming ASP.NET by Jesse Liberty and dan Hurwitz
Essential ASP.NET With Examples in C#
Best Regards,
Apurva Kaushal
|
|
|
|
|
Asp.net2.0 books by wrox publication.
With Regards
Satips
|
|
|
|
|
And ofcourse Code Project Articles..
Best Regards,
Apurva Kaushal
|
|
|
|
|
hi,
I think wrox publications is better for asp.net
suresh babu.k
|
|
|
|
|
hi i have already mentioned.
With Regards
Satips
|
|
|
|
|
Can any one plzzzz let me know the reasons opf session log out whether the ASP.Net state service is running or not, plz reply me ASAP.
|
|
|
|
|
1. sessionTimeout
2. changes made in web.config/machine.config
3. Reset IIS
4. aspnet work-processor is overloaded.
5. Application shutdown
|
|
|
|
|
You probably missed one thing if the user is not interactime for a specific period then also there will be session timeout.
Best Regards,
Apurva Kaushal
|
|
|
|
|
wht can be the reasons if my session mode is state server ?
|
|
|
|
|
thankx for ur reply, what can be the other possible reasone other then mentioned above?
|
|
|
|