net 4.0 page validator undefined - c#

Web form with .Net validators works perfectly on the development server.
On the production server, .Net seems to fail to generate client side script 'Page_ClientValidate' and browser throws 'Page_ClientValidate is undefined'
Can't seem to figure out what the issue is? Is there a setting in IIS or server level to fix the issue?
Please help, have been trying to resolve it for days with no luck.
function ValidateForm() {
var validForm = true;
Page_ClientValidate("formWrapperValidationGroup");
validForm = validForm && Page_IsValid;
if (validForm) {
$("#formWrapper .fieldSubmitButton input[type=submit]").css("display", "none");
$("#formWrapper .fieldSubmitButton .fieldSubmitButtonStatus").css("display", "inline-block");
}
return validForm;
}

Try this:
$('#Form1').submit(function () {
if (typeof (Page_ClientValidate) == 'function') {
Page_ClientValidate();
} else {
$(this).valid();
}
});

js.axd?path=%2fWebResource.axd - Redirect rule caused an issue with resolving the js.axd file path. Fixed it b fixing the redirect rule.

Related

Stop process if webBrowser control hangs

I am using the WebBrowser control.
This works fine most of the time however wehn navigating to a new page or waiting for a new page to load can sometimes hangs.
Is there a way to catch this? i.e. if the page is failing to navigate or load after a certain amount of time then kill the process?
I am using the - webBrowser1_DocumentCompleted event to pick up ertain behaviours when the page loads/navigates as expected however not sure how to catch if a page is hanging??
Maby you should try to implement some kind of timeout logic? There are quite many samples in web about this. F.e. this one
Also you might be interested in this event of WebBrowserControl ProgressChanged
This is due to that webbrowser component is very basic model of internet explorer, and it get stuck at ajax pages. You can fix this problem explicitly to use latest version of internet explorer... Using this code...
try
{
string installkey = #"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
string entryLabel = "YourExe.exe";
string develop = "YourExe.vshost.exe";//This is for Visual Studio Debugging...
System.OperatingSystem osInfo = System.Environment.OSVersion;
string version = osInfo.Version.Major.ToString() + '.' + osInfo.Version.Minor.ToString();
uint editFlag = (uint)((version == "6.2") ? 0x2710 : 0x2328); // 6.2 = Windows 8 and therefore IE10
Microsoft.Win32.RegistryKey existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, false); // readonly key
if (existingSubKey.GetValue(entryLabel) == null)
{
existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
existingSubKey.SetValue(entryLabel, unchecked((int)editFlag), Microsoft.Win32.RegistryValueKind.DWord);
}
if (existingSubKey.GetValue(develop) == null)
{
existingSubKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(installkey, true); // writable key
existingSubKey.SetValue(develop, unchecked((int)editFlag), Microsoft.Win32.RegistryValueKind.DWord);
}
}
catch
{
MessageBox.Show("You Don't Have Admin Previlege to Overwrite System Settings");
}
}
Right Click Both your Exe. And vshost.exe and Run as Administrator To Update Registry for this Application....

Some specific Special Characters are getting blocked in my server

I have a problem with my LIVE Server IIS, which I am not facing in my local server IIS. The characters like '|| ||' are getting blocked in my server, when those are present in any textboxes. The server is allowing if the single character is present '|'. Unable to find the correct reason for this. Only if the above specified characters are present in any of the text boxes in the page, then page redirection is not happening. Can any one has already faced this problem, please help me in solving this. If I remove the characters from text boxes, then the page redirections are happening perfectly.
EDIT :
The page from client side is not going to server side, in a single shot the button events are getting blocked and not working. After removing the above mentioned special characters, the button events are firing in the page. Its happening only in my LIVE server, but not in my local. This has been happening from recently before everything was working fine, hope some of my DBAs has changed/enabled some configuration in IIS, but don't know what is that? Please, help.
<script type="text/javascript" language="javascript">
function ValidateFilegrid()
{
document.getElementById('<%=HidValid.ClientID %>').value = "";
var gridView = document.getElementById('<%=GVUploadedDocs.ClientID %>');
for (var i = 1; i < gridView.rows.length; i++)
{
var radio = gridView.rows[i].getElementsByTagName('input');
var selectedvalue;
for (var j = 0; j < radio.length; j++)
{
if (radio[j].checked)
{
selectedvalue = radio[j].value;
break;
}
}
var inputs2 = gridView.rows[i].getElementsByTagName('button')[0];
if (selectedvalue != "Yes")
{
var inputs = gridView.rows[i].getElementsByTagName('input')[0];
if (inputs != null)
{
if(gridView.rows[i].getElementsByTagName('input')[1].value.length > 3)
{
if (inputs.value.length<3)
{
alert("Enter File Validation Remarks !!");
return false;
}
else
{
document.getElementById('<%=HidValid.ClientID %>').value ="N";
}
}
}
}
}
return true;
}
</script>

Windows Service doesn't read settings.setting?

I have a Setting.setting have a setting option : isSent - type int - value : 0
And my code :
if (Settings.Default.isSent =! 0)
{
var info = _text.ReadFile(Settings.Default.FilePath);
//Do something
} else
{
//Do something
}
I install my Windows Service, start and attach it to Visual to debug, and it always run to
var info = _text.ReadFile(Settings.Default.FilePath);
But not run to
} else
{
//Do something
}
like I expect :(
Anyone can explain it and know how to solve this for me ? Appreciate any answer :)
I just noticed "if (Settings.Default.isSent =! 0)". Should it be "if (Settings.Default.isSent != 0)". Otherwise visual studio will always report error.
by the way, have you tried to attach your source code to the Service and see the value of "Settings.Default.isSent" at runtime?

C# code behaves differently in localhost vs live server

I have the following C# code in my code behind for a regular Web Application:
protected void Page_Load(object sender, EventArgs e)
{
if (!validTime())
{
btnEdit.Enabled = false;
btnSubmit.Enabled = false; btnSubmit2.Enabled = false;
lblSuccess.Text = "It is not currently the time to edit picks for this week.";
lblSuccess.ForeColor = System.Drawing.Color.Red;
if (picksMade())
{
displayCurrentPicks();
}
}
else
{
if (picksMade())
{
btnEdit.Enabled = true;
btnSubmit.Enabled = false;
btnSubmit2.Enabled = false;
displayCurrentPicks();
lblSuccess.Text = "Viewing your current picks";
lblSuccess.ForeColor = System.Drawing.Color.Green;
if (Session["Success"] != null && Session["Success"].ToString() != String.Empty)
{
lblSuccess.Text = Session["Success"].ToString();
lblSuccess.ForeColor = System.Drawing.Color.Green;
Session.Remove("Success");
}
}
else
{
btnEdit.Enabled = false;
btnSubmit.Enabled = true; btnSubmit2.Enabled = true;
displayCreatePicks();
lblSuccess.Text = "Create your picks for this week";
lblSuccess.ForeColor = System.Drawing.Color.Green;
}
}
}
The problem is, this code works great when I test it using ASP.NET Development Server. When I publish it to my live server it has some different behavior.
I have a web method that inserts data into my database with this signature:
[WebMethod]
public static void savePicks(List<string> Points, List<string> Teams, List<string> TieBreaker)
Again, on the test server it runs and works great. The problem is, when the method returns it should refresh the page, and it does, but on the live server my code in the page_load event is not run? or is run differently? It never calls the displayCurrentPicks() method? Or if it does, it does not run correctly? except it runs perfectly on the test server.
I have no way to check this stepping through the code because when I do it works great, on the test server. The live server is hosted on Godaddy.
And I have tried everything. I have tried doing page refreshes after the correct methods and in my javascript to force the page_load event to be run again. Nothing works. I have been at this for a few days now. And I am sure all my code is publishing. I have done all the usual 'stupid checks'. The data is making it to the database, the picksMade() function returns true when there is data there. The data is there by the time the page refreshes.
Why does the live server not run the code I publish to it? Why does it run something different? Or Behave differently? I understand it is a different server, but shouldn't it run the code the same?
What exactly does the function validTime() do? If you are checking for specific time constraints it may be that your development server is set to your local time zone and that is why it is working but on your live server the timezone may be different. Just a guess though.

C# SAPI in a web service

var speechEngine = new SpVoiceClass();
SetVoice(speechEngine, job.Voice);
var fileMode = SpeechStreamFileMode.SSFMCreateForWrite;
var fileStream = new SpFileStream();
try
{
fileStream.Open(filePath, fileMode, false);
speechEngine.AudioOutputStream = fileStream;
speechEngine.Speak(job.Script, SpeechVoiceSpeakFlags.SVSFPurgeBeforeSpeak | SpeechVoiceSpeakFlags.SVSFDefault); //TODO: Change to XML
//Wait for 15 minutes only
speechEngine.WaitUntilDone((uint)new TimeSpan(0, 15, 0).TotalMilliseconds);
}
finally
{
fileStream.Close();
}
This exact code works in a WinForm app, but when I run it inside a webservice I get the following
System.Runtime.InteropServices.COMException was unhandled
Message="Exception from HRESULT: 0x80045003"
Source="Interop.SpeechLib"
ErrorCode=-2147201021
Does anyone have any ideas what might be causing this error? The error code means
SPERR_UNSUPPORTED_FORMAT
For completeness here is the SetVoice method
void SetVoice(SpVoiceClass speechEngine, string voiceName)
{
var voices = speechEngine.GetVoices(null, null);
for (int index = 0; index < voices.Count; index++)
{
var currentToken = (SpObjectToken)voices.Item(index);
if (currentToken.GetDescription(0) == voiceName)
{
speechEngine.SetVoice((ISpObjectToken)currentToken);
return;
}
}
throw new Exception("Voice not found: " + voiceName);
}
I have given full access to USERS on the folder C:\Temp where the file is to be written. Any help would be appreciated!
I don't think the System.Speech works in windows service. It looks like there is a dependency to Shell, which isn't available to services. Try interop with SAPI's C++ interfaces. Some class in System.Runtime.InteropServices may help on that.
Our naming convention requires us to use a non-standard file extension. This works fine in a Winforms app, but failed on our web server. Changing the file extension back to .wav solved this error for us.
Make sure you explicitly set the format on the SPFileStream object. ISpAudio::SetState (which gets called in a lower layer from speechEngine.Speak) will return SPERR_UNSUPPORTED_FORMAT if the format isn't supported.
I just got the webservice to spawn a console app to do the processing. PITA :-)

Categories

Resources