|
Three things wrong here
1 - you're treating ASP.NET as if it was ASP - stop it. You should put all your code in the code behind, not inline
2 - C# runs on the server, jscript runs on the client, they will never be able to see each other
3 - This is best asked in the ASP.NET forum.
In your code behind you can use the InsertClientScriptBlock ( from memory ) function to insert jscript into the generated code. You should call this in your codebehind, assuming you have a meaningful example, as opposed to what you posted.
Actually, your jscript could use findelementbyID to find your textbox and get it's value.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
Can you please send me sample example using InsertClientScriptBlock
Thanks
|
|
|
|
|
|
Yeah, I thought I may have the name wrong....
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
i would like to send a live stream webcam image over a local area network with C#
but i don't have any information about it...
do you guys have some information about it...
|
|
|
|
|
Hi all,
I'm working with VC++ for several years and have used the MFC libraries to create all my applications.
But now I need to use C# to make a thick client application. In order to make it user friendly I certainly need to use threads. In VC I used both 'Worker' and 'User' threads, so I want to use both in the new client. Although I found how to use worker threads, I didn't find any references how to create user threads in C#.
Does anyone has any thougts on how to implement a user thread in c#?
Thx in advance
codito ergo sum
|
|
|
|
|
Include System.Threading in your using list:
--------------------
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Diagnostics;
using System.ServiceProcess;
using System.Threading;
using System.Configuration.Install;
using System.Reflection;
Define your threading variables:
--------------------
private static System.Threading.Thread ReadFromDTThread;
private static System.Threading.Thread IsAliveThread;
private static System.Threading.Thread WriteToLX1Thread;
private static System.Threading.Thread IsActiveThread;
-----
and any global variables in your class:
-------
private System.ComponentModel.Container components = null;
private static System.Collections.Queue LX1Queue = new Queue();
private static System.Text.StringBuilder datatracSql = new System.Text.StringBuilder(5000);
private System.ComponentModel.Container components = null;
private static System.Collections.Queue LX1Queue = new Queue();
private static System.Text.StringBuilder datatracSql = new System.Text.StringBuilder(5000);
private volatile static int RestartCount = 0;
private volatile static bool InterfaceStop = true;
private volatile static bool InterfacePaused = true;
private volatile static bool Interface1Alive = false;
private volatile static bool WriteToLX1Alive = false;
---------------
Declaring boolean and integer variables volatile tells the compiler to make no assumptions about the state of variables. It makes simple operations on these variables safe for multithreading without the need for locking (atomic).
Write your methods that will be performed in your threads:
--------------
private static void WriteToLX1()
{
int ErrorCount = 0;
int qCount = 0;
if (generalSwitch.TraceInfo)
Trace.WriteLine("DT2LXInterface:WriteToLX1 has started.");
while (true)
{
//Set Alive flag so that IsAlive knows thread is running
WriteToLX1Alive = true;
Hashtable LoanData;
//Lock queue use SyncRoot to perform sync on objects that have this method
lock (LX1Queue.SyncRoot)
{
qCount = LX1Queue.Count;
}
if (qCount == 0)
{
//Flush the current sql statements--write all pending data to LX when queue goes empty
LXData.IAccess.ExecuteBatchAdHocFlush();
//End thread if there are no records in the queue and interface is stopping
if (InterfaceStop)
return;
Thread.Sleep(InterfaceCycleTime);
continue;
}
lock(LX1Queue.SyncRoot)
{
LoanData = (Hashtable)LX1Queue.Dequeue();
}
NBPropertyBag getInfo = new NBPropertyBag();
getInfo.Contents = LoanData;
string AcctNO = getInfo.ReadProperty("_accountnumber");
string Label = getInfo.ReadProperty("_label");
string FileID = getInfo.ReadProperty("_fileid");
if (generalSwitch.TraceVerbose)
{
Trace.IndentLevel =0;
Trace.WriteLine("");
Trace.WriteLine(System.DateTime.Now.ToString());
Trace.WriteLine("--------------- DT2LXInterface:WriteToLX1 Determine BLL Start ----------------");
Trace.Indent();
Trace.WriteLine("AcctNO/Label/FileID" + AcctNO + "/" + Label + "/" + FileID);
Trace.Unindent();
}
// Use label to determine which BLL to Call
try
{
switch (Label)
{
case "GenUpdate":
clsDt2LXGenBLL.HandleMessage(LoanData);
break;
case "UndUpdate":
clsDT2LXUndBLL.HandleMessage(LoanData);
break;
case "MktUpdate":
clsDT2LXMktBLL.HandleMessage(LoanData);
break;
case "FunUpdate":
clsDt2LXFunBLL.HandleMessage(LoanData);
break;
case "FeeUpdate":
clsDT2LXFeeBLL.HandleMessage(LoanData);
break;
case "ImpUpdate":
clsDT2LXImpBLL.HandleMessage(LoanData);
break;
case "ActUpdate":
clsDT2LXActBLL.HandleMessage(LoanData);
break;
case "MersUpdate":
case "MersMomUpdate":
clsDT2LXMersBLL.HandleMessage(LoanData);
break;
case "ELIUpdate":
clsDT2LXELIBLL.HandleMessage(LoanData);
break;
case "CorUpdate":
clsDT2LXBrokerBLL.HandleMessage(LoanData);
break;
};
if (generalSwitch.TraceVerbose)
{
Trace.IndentLevel = 0;
Trace.WriteLine("--------------- DT2LXInterface:WriteToLX1 Determine BLL Finished ----------------");
}
StagedLoansProcessed++;
//Data from datatrac was added without any issues
ErrorCount = 0;
if (DT2LXBaseBLL.status != 0)
{
//There were minor issues
LogUtil.AddToInfoRow(AcctNO, FileID, "1", "1" + Label, DT2LXBaseBLL.issue);
DT2LXBaseBLL.ClearIssue();
}
}
catch (Exception e1)
{
if (generalSwitch.TraceError)
{
Trace.IndentLevel = 0;
Trace.WriteLine("");
Trace.WriteLine(System.DateTime.Now.ToShortDateString());
Trace.WriteLine("-----------Error in WriteToLX1----------------");
Trace.Indent();
Trace.WriteLine(e1.Message);
Trace.WriteLine("AcctNO/Label/FileID" + AcctNO + "/" + Label + "/" + FileID);
Trace.IndentLevel =0;
Trace.WriteLine("-----------Error in WriteToLX1----------------");
}
if (e1.Message.IndexOf("ORA-01033") > -1 || //Oracle shutdown
e1.Message.IndexOf("ORA-12154") > -1 || //Bad TNS name
e1.Message.IndexOf("ORA-01017") > -1 || //Bad userID/password
e1.Message.IndexOf("ORA-06576") > -1) //stored procedure not found
{
//Can not recover from these errors; shutdown interface
EventLog.WriteEntry(MyServiceName, "Non-recoverable error--terminating WriteTOLX1: " + e1.Message ,
EventLogEntryType.Error);
WriteToLX1Alive = false;
return;
}
//Data from datatrac was not added to LX for some reason
//Try again
string secondTry = getInfo.ReadProperty("_secondtry", "F");
if (secondTry == "F")
{
getInfo.WriteProperty("_secondtry", "T");
LoanData = getInfo.Contents;
lock (LX1Queue.SyncRoot)
{
LX1Queue.Enqueue(LoanData);
}
}
if (ErrorCount > MaxErrorCount)
{
EventLog.WriteEntry(MyServiceName, "More than" + MaxErrorCount.ToString() + " errors in succession, terminating WriteToLX1 thread. Thread will be restarted.", EventLogEntryType.Warning);
WriteToLX1Alive = false;
return;
}
}
}
}
------
Then you can start the thread in the main class by calling:
--------
//The method on this thread will try to Send loan to LX
//If it fails to import the loan it will update the try count by one
WriteToLX1Thread = new Thread(new ThreadStart(WriteToLX1));
WriteToLX1Thread.Name = "WriteToLX1";
WriteToLX1Thread.Priority = ThreadPriority.AboveNormal;
WriteToLX1Thread.Start();
//Allow thread to execute on uniproccessor machine
Thread.Sleep(0);
-------
The Thread.Sleep(0) must be done after creating the thread to make it safe for uniproccessor machines. If you do not call this on a uniproccessor machine the child thread will never start.
|
|
|
|
|
My query is i have some data which i want to run every 5 minutes for 6 hours duration right from 8am to 2pm for about a month. the data should run only on those specified duration else the timer should stop. how can i proceed this with the timer control
kalyan
-- modified at 3:55 Monday 8th May, 2006
|
|
|
|
|
Well, I guess DateTime.Now to work out if it's inside the timeframe you want, and run the timer in shorter intervals if it's vital it start at exactly 8 am, then set it to run every five minutes until 2 pm is passed.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Can anyone tell me:
How to write a C library routine that will invert the pixels in an image,horizontally or vertically flip an image ,use a kernel to edge detect an image and emboss an image?
May be need all your help to solve my program. Hence give the source code for this program.
From: SYS86
|
|
|
|
|
|
SYS86 wrote: Hence give the source code for this program.
Wow, you're really lost, aren't you ? :P
There are three programming languages you may be talking about here.
1/ C. That's what you said
2/ C++ - I guess it's possible
3/ C# - seeing as you asked in the C# forum.
If it's 3, then C is a different language, you need to say C#. As I said elsewhere, this is too complex a task for anyone to just write the source code in response to a forum question. However, my series of articles on image processing covers all of this ( in C# ), so just search for "graus image" in the site ( actually, google would probably do it as well ) and you may well find all you need. Unless you meant C. Then, ask in the C++ forum, as C++ is a superset of C, it's as close as we've got.
And for C or C++, BitBlt will invert with SRCINVERT, and will flip if you give it negative co-ordinates in the direction you want to flip.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
How could i change ToolBar BackColor (C# - Visual Studio 2003). There is no such property available in VS 2003 like "ToolBar.BackColor", though it can done in VS 2005. Please tell me the way out.
Partha De
|
|
|
|
|
|
I have to create a special but very basic text editor with the following features:
- export to special XML format (main feature)
- export as normal text format
- export to HTML (optional)
- export to RTF (optional)
- A predefined styles can be applied to the text (this is not necessary to be WYSWYG)
I need just directions for now (no source code), just an idea where to look at. Where should I start? What control to use for entering text? How to do the XML output? Do I need to write a custom text box control?
Thank you very much in advance!
|
|
|
|
|
hmmm, a refreshing question - most similar posts here ask for SOURCE CODE NOW PLEASE THX URGENT!!!111
A text editor is basically just a big multi-line textbox and a main menu (New File, Save File, Exit etc), you should be able to "knock up" this quick sample before trying anything more complex.
Your "special XML format" is a main feature, but youve provided little detail on what you want to do, and depending on how difficult you want to go you could do anything up to a full-blown XML editor (Check out a demo of XMLSpy if you get a chance).
Based on some guesswork, you might want to have some simple "tags" defined, where the style would be added after..
[heading]This is my heading[/heading]
[bodyText]This is my body text[/bodyText]
This could also be interpreted to form an XML document, an HTML document and an RTF document. There are many object-oriented ways to achieve such a pattern (thing Formatter which takes the raw text and spits out the HTML,RTF,XML etc.)
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I'll try to explain what I want to do. Maybe there is a better way but I do not know about.
I need to enter text. Let's say it is a poem. A poem has staves, verses a title, notes, etc. Currently if I do this I have to write all these XML tags manually. For a few things it is perfectly OK but with time it gets tedious work.
Example:
Great poem
by Greatest Poet of all times
A great poem I wrote,
a great poem you read.
To write another stave
you must be brave.
<code><title>Great poem<title>
<author>by Greatest Poet of all times</author>
<stave><verse>A great poem I wrote,</verse>
<verse>a great poem you read.</verse></stave>
<stave><verse>To write another stave</verse>
<verse>>you must be brave.</verse></stave></code>
Note: this is just an example but it shows basically what I want to do. I do not need to have a full XML editor.
I basically imagine it like having a text box where I type the text and on the left I select the style for each paragraph (row) like this:
title: Great poem
author: Greatest author of all time
verse: a verse
verse: a second verse
and the editor will add the rest of the tags as necessary.
Last note: Then the XML files will be transformed with XSLT into HTML or used as necessary.
|
|
|
|
|
OK, that all makes sense and you seem to have the right idea when it comes to building your XML and using it.
So what part do you think you need help on? Sounds to me like you could have a stab at trying to create this text editor and post any specific coding questions if you get stuck!
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|
|
I haven't touched .NET for 2 years so I don't remember much.
The main problem is: if I use textbox ot richtextbox how can I output it's contents into the required XML format. For example it's not clear to me. How should I recognize if a character has some special formatting and also how can I add for example a area where the number of a given line is displayed, it's style, etc.
I hope it is understandable.
|
|
|
|
|
I need to develop a small application,
from which i need to insert data into the SQL Server.
I am using ADO.Net.
pls give me some sample code if possible.
or refer me to a suitable article.
Thank U.
|
|
|
|
|
Hello dear friend
Please notice below codes
We have a table with 3 fields as :
(field1:Int, field2:NVarChar, field3:Bit)
At first of your form add these namespaces:
<br />
using System.Data;<br />
using System.Data.SqlClient;
Now add these sample lines to your Button_Click() event :
<br />
string strInsert="INSERT INTO table (field1,field2,field3) VALIUES (@field1,@field2,@field3)";<br />
if (SqlConnection1.state.toString() != "Open")<br />
SqlConnection1.Open();<br />
sqlCommand cmd = new SqlCommand(strInsert,sqlConnection1);<br />
cmd.Parameters.Add(new SqlParameter("@field1",SqlDbType.Int,4,"field1"));<br />
cmd.Parameters["@field1"].Value = 1000;<br />
cmd.Parameters.Add(new SqlParameter("@field2",SqlDbType.NVarChar,10,"field2"));<br />
cmd.Parameters["@field2"].Value = "California";<br />
cmd.Parameters.Add(new SqlParameter("@field3",SqlDbType.Bit,1,"field3"));<br />
cmd.Parameters["@field3"].Value = true;<br />
cmd.ExecuteNonQuery();<br />
Don't remember to define SqlConnection
if you have any problem mail me
Bye Bye
-- modified at 2:13 Monday 8th May, 2006
|
|
|
|
|
Really i am very thankfull 2 U.
|
|
|
|
|
for vb.net and asp.net
imports system.data.sqlclient
dim con as new sqlconnection
dim cmd as new sqlcommand
con.connectionstring = "Provider= the provider u use;user id= ;password= ;
data source= sql server name ;initial catalog= database name "
cmd.connection = con
con.open()
cmd.commandtext = "insert into tablename values('" & tid.text & "')"
cmd.executenonquery()
con.close()
if u have any problem with this revert back vil help u out
regards
kalyan
|
|
|
|
|
Hi..
I want to use the CmdLoadFromResource() method of ths speech SDK 5.1 to make the xml file that includes the Grammar embeded but i dont know how to use this method in C#.
This code shows how i used this method:
[System.Runtime.InteropServices.DllImport("kernel32")]
private static extern long LoadLibrary(string lpLibFileName);
private void button2_Click(object sender, System.EventArgs e)
{
this.objRecoContext = new SpSharedRecoContext();
this.objRecoContext.Recognition += new _ISpeechRecoContextEvents_RecognitionEventHandler(RecoContext_Recognition);
this.objRecoContext.State=SpeechRecoContextState.SRCS_Enabled;
grammar = objRecoContext.CreateGrammar(0);
int hModule=Convert.ToInt32(LoadLibrary("ReviewWinApp.dll"));
int langID=409;
grammar.CmdLoadFromResource(hModule,"tryRecog.xml","CFGGRAMMAR",langID,SpeechLoadOption.SLODynamic);
grammar.State=SpeechGrammarState.SGSEnabled;
grammar.CmdSetRuleIdState(1,SpeechRuleState.SGDSActive);
}
When i click this button i got the error:
An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ReviewWinApp.exe
Additional information: The specified resource type cannot be found in the image file.
Iam not good in COM programming.Could any one give me a C# code sample for using this method?
|
|
|
|
|
Hi everybody,
I want to call a secure web page through desktop application. Though .net automatically validates it but i want to get the exact status of error. In previous version certificatePolicy property of ServicePointManager was used for this purpose but now it is obsoleted. They have provided another function ServerCertificateValidationCallback but when I reach at the statement, it gives an error :
"System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."
|
|
|
|