|
I tried this way also.. But it is not working
Ranjith
|
|
|
|
|
There are some set of server controls its property enabled= may be true or false,now in code behind how to find its current state and i am getting the controls id during runtime like this
foreach(Control c in form1.Controls)
{
............
}
and also there is no property like (c.Enabled) to check
Thanks In Advance
|
|
|
|
|
vamsimohan21 wrote: foreach(Control c in form1.Controls)
{
............
}
A web form has a Controls collection, the trick is that it's a tree, so you need to recurse over it.
Christian Graus - C++ MVP
|
|
|
|
|
Thank sir for that and i tried with that but not got any solution can u just pls tell me any sample code and also how to know whether the control is enabled or in disabled state during runtime
Thanks In Advance
|
|
|
|
|
Web controls do in fact have an Enabled property. I just checked. Maybe you need to post your code ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
protected void Button1_Click1(object sender, EventArgs e)
{
foreach(Control c in mainform.Controls)
{
if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1)
{
(//HERE I HAVE TO CHECK WHETHER THE CURRENT CONTROL IS IN ENABLED/DISABLED STATE)
if (c.Enabled)
//Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled' C:\Documents and Settings\vamsi\My Documents\Visual Studio 2005\WebSites\WebSite1\Default.aspx.cs 86 23 C:\...\WebSite1\
{
.................
}
}
}
The above is the error i am reciving sir
THANKS IN ADVANCE
|
|
|
|
|
vamsimohan21 wrote:
if (String.Compare(c.GetType().ToString(), "System.Web.UI.LiteralControl") == 1)
What on earth is this ? It's a mess.
if (c is LiteralControl)
{
// etc
}
vamsimohan21 wrote: //Error 4 'System.Web.UI.Control' does not contain a definition for 'Enabled'
Perhaps you need to have a derived class to have that property ?
LiteralControl lc = c as LiteralControl;
if (lc != null & lc.Enabled)
{
// Whatever
}
This still won't work, unless you just didn't bother to post the code that causes it to be recursive, but I don't see how it can be.
Christian Graus - C++ MVP
|
|
|
|
|
Hi
I began writing a c# program and everything was going ok until i tried to use asynchronous webrequests instead of synchronous ones (since the UI would be unresponsive while it was fetching the response) and i have a slight problem:
the user signs in by clicking a button on the form - the program fetches the data from the server asynchronously - the problem is with the callback function - when debugging i see that the request was successfully completed but when i try to access any controls (like filling a textbox with the response) from the callback function it just stop executing the function - no exceptions, no errors - i can still interact with the program but it just wont alter anything to do with the form's controls (the form's data members however were being altered with no issues - a string and an integer to be exact)
I'm a newbie at c# and i just started using the asynchronous method so if im doing sumthing wrong please advise
thank you for your time
|
|
|
|
|
A good first step would be to post some code, so we can offer some advice on it.
Christian Graus - C++ MVP
|
|
|
|
|
Hi
thanks for your quick reply
these are methods of my MainForm class (base class is Form)
<br />
private void getResult(String url, AsyncCallback callback)<br />
{<br />
try<br />
{<br />
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);<br />
request.Method = "GET";<br />
if(useCompression)<br />
request.Headers.Add("Accept-Encoding: gzip,deflate");<br />
request.CookieContainer = mainCookie;<br />
request.AllowAutoRedirect = true;<br />
request.AllowWriteStreamBuffering = true;<br />
<br />
IAsyncResult result = request.BeginGetResponse(callback, request);<br />
}<br />
catch (WebException wex)<br />
{<br />
MessageBox.Show("Error Connecting: Check your connection settings...\nDetails: " + wex.Status.ToString());<br />
return;<br />
}<br />
}
<br />
private void SignInButton_Click(object sender, EventArgs e)<br />
{<br />
DisableSignInControls();<br />
String url = mirror + "signin.aspx?user=" + UserNameComboBox.Text + "&pass=" + PasswordTextBox.Text;<br />
mainCookie = new CookieContainer();<br />
getResult(url, new AsyncCallback(signIn));<br />
}<br />
<br />
<br />
private void signIn(IAsyncResult result)<br />
{<br />
HttpWebRequest request = (HttpWebRequest)result.AsyncState;<br />
HttpWebResponse response = (HttpWebResponse)request.EndGetResponse(result);<br />
String responseResult = (useCompression ? decompressResponse(response) : new StreamReader(response.GetResponseStream()).ReadToEnd());<br />
int i = responseResult.IndexOf("<response>");<br />
if (i < 0)<br />
MessageBox.Show("Corrupt response. Please try again.");<br />
else<br />
{<br />
int j = responseResult.IndexOf("</response>");<br />
String temp = responseResult.Substring(i + 10, j - i - 10);<br />
if (temp != "")<br />
{<br />
String[] returnValues = temp.Split('|');<br />
if (returnValues.Length == 1)<br />
MessageBox.Show(returnValues[0]);<br />
else<br />
{<br />
sid = returnValues[0];<br />
num_messages = int.Parse(returnValues[1]);<br />
MessageNumber.Text = "Messages: Left " + num_messages;<br />
SignInGroupBox.Visible = false;<br />
SendSMSGroupBox.Visible = true;<br />
SignOutMenu.Visible = true;<br />
FillContacts();<br />
}<br />
}<br />
}<br />
EnableSignInControls();<br />
FillUsers();<br />
}<br />
the other functions are also part of the mainform class and they all make changes to the controls on the form.
do you need more info?
thanks again.
|
|
|
|
|
wajih.boukaram wrote: IAsyncResult result = request.BeginGetResponse(callback, request);
Doesn't result just get discarded ? And where is the callback hooked up to a method ?
Christian Graus - C++ MVP
|
|
|
|
|
yea it does but all that matters is the callback function (which i assigned when i called getResult(url, new AsyncCallback(signIn));
so its hooked up to signIn
it works fine the way it is - only problem is changing the form's control values - i think it might have something to do with threading because if i try calling the function a second time (I hate c# sometimes) it says sumthin about accessing an object that was not created on the same thread - when i first tried to do this asynchronously i actually just created a new thread that called my initial signIn function which was just a regular function and not a callback - i got the same error message when acessing the controls.
any suggestions?
thanks for your replies.
|
|
|
|
|
I was just wondering if anyone has managed to create a C# object that is exposed as a COM object and successfully insert it into the Running Obhect Table (ROT). Just as important, once in the table have you been able to extract it and actually call a method on it.
To test this, I have created two projects. The first one creates the C# object and inserts in into the ROT. It then waits until cancelled. The second one attempts to retrieve the object from the ROT. The second project contains a reference to the dll that contains the C# object created in the first project.
I believe I can successfully insert the object into the Running Object Table. As I can see the object in the ROT if I dump the contents.
When I try to access the entry, I seem to be able to pull it out of the table. But when I try to bind to the object
<br />
iMoniker.BindToObject(ctx, iMoniker, ref IID_ICancelAutoplay, out o);<br />
I get a "System.IO.FileNotFoundException" indicating "The specified module could not be found (Exception from HRESULT:0x8007007e)".
Any thoughts, hints would be greatly apreciated. I'd even be willing to be spoon feed on this one.
Thanks
Tim
|
|
|
|
|
Hi all,
I'm currently making an application for graphical manipulation of data. (i.e. a graph) Due to the interaction requirements I've used opengl to do the rendering due to its great speed. The problem I'm having is concerning the rendering strings/fonts.
I'm currently using the Tao libraries and the glutBitmapString function to render my text which has sufficed until now. On the Y axis of the graph I need to be able to render the text of the axis label vertically, as is common. Yet I cannot find anything to do this.
I've looked at the NeHe tutorials about rendering fonts, but they seem to be all in C++ and I cant find anything that will work in C#.
Does anyone have any ideas of how I go about doing this? I'd really appriciate any help at this point as currently I'm at a total loss.
|
|
|
|
|
Does glRotatef( -90, 0, 0, 1) (or whatever the Tao equivalent is) before calling glutBitmapString work?
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
No, unfortunately not. I don't think that glutBitmapString has the ability to render text at any angle. I've looked for an alternative font library, but I either can't find a suitable one, or they are not created for use in C#
Edit: I've also tried using the glutStrokeString function, but I cant get this to render anything at all.
-- modified at 6:55 Thursday 16th November, 2006
|
|
|
|
|
hi
i want to get position of my datarow in dataset, How to do that ??
i am using vC# 2005
thanks
|
|
|
|
|
Well, a DataSet doesn't contain rows directly. Rather, it contains DataTables, which then contain rows. To find a row in a table in a dataset, you need to iterate over all the DataTable objectss, then look for the row in each table. Something like this:
int GetIndexOfRow(DataSet dataSet, DataRow row)
{
foreach(DataTable table in dataSet.Tables)
{
int index = table.Rows.IndexOf(row);
if(index != -1)
{
return index;
}
}
return -1;
}
|
|
|
|
|
I am displaying blocks of text in a datagridview control. The column is setup to not wrap or size. The first x characters are shown and then truncated. Since the column type is string, the datagridview shows the entire cell contents in a tooltip. Is there a way to control the font of this default behavior? I just need to increase the font size from what looks to be 10pt to 12pt or 14pt.
Any information would be greatly appreciated.
Steve
|
|
|
|
|
Did you find the solution....? I am also stuck in the same problem.
dfdfd
|
|
|
|
|
I downloaded the 'Building a Data Access Layer - The Demo Application' by Damon Armstrong. I want to use the DataServiceBase class that he built in another application. I do not want to use the PersonDataService that he has in the same Namespace. To make a long story short, I copied the class that I want to a new C# Class Library. There is only one problem, it won't compile. I get the following error:
The name 'ConfigurationManager' does not exist in the current context C:\HAA_C_Library\DataServiceBase\DataServiceBase.cs
Here is the method that causes the error:
protected static string GetConnectionString()
{
return ConfigurationManager.ConnectionStrings["DB"].ConnectionString;
}
I have the following before the start of the class:
using System.Configuration;
When I go to the Object Browser, it shows ConfigurationManager as a class within System.Configuration. Yet, when I try to use it; it is not there. When I go to the original code that I downloaded, it behaves as desired.
What is happening here? I've looked at everything I know to look at and can't see any difference between the original code and mine. But one works and one doesn't.
Thanks in advance,
Mary
|
|
|
|
|
Well, after trying almost everything. I got it to work. I added System.Configuration to the References section. Now all is fine. Evidently, it was not using the correct library.
|
|
|
|
|
No, you were using the correct library you just hadn't told the compiler to link it in, so although it was importing the System.Configuration namespace it couldn't actually find it.
|
|
|
|
|
i wanna to know how can i generate an algorithm by using DNA computing to solve A/B problem? is it NP complete?
SUMA
|
|
|
|
|
bool isA = false;
bool isB = false;
foreach (chromosome c in theCell)
foreach (gene g in c)
{
if (g == KnownGenes.BloodTypes.A)
isA = true;
if (g == KnownGenes.BloodTypes.B)
isB = true;
}
if (isA && isB)
printf("type AB");
else if (isA)
printf("type A");
else if ( isB)
printf("type B");
else printf("type O");
--
Rules of thumb should not be taken for the whole hand.
|
|
|
|