|
You can achive this through static variables in your webapplication. And onething more we dont use controls in webservice.
Shujaat
|
|
|
|
|
I have a page which has certain required fields.In order to validate them i am using Required Field Validators.
Now on my save button i have added the attribute
btnSave.Attributes.Add("OnClick", "return OnSaveClick();");
function OnSaveClick()
{
if(document.getElementById('ctl00$ContentPlaceHolder1$txtOneTouchUserName').value.length >0 && document.getElementById('ctl00$ContentPlaceHolder1$txtOneTouchPassword').value.length >0)
{
if(window.confirm("Are you sure you want to save configuration settings and log off ?"))
return true;
}
}
This java script function basically displays a Confirmation box ...
Now , the problem is that when i click save post back occurs and then the .net validation occurs, in case i dont add the HTML onclick event to the save button then the validation occurs without post back.
How do i prevent post back without removing the onclick java script.
|
|
|
|
|
return false;
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
In case i return false in javascript ,the postback dosent occur but neither does the validation ocuur
|
|
|
|
|
would you explain one more as i am not getting properly what you have written
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
When i click save button postback occurs even though validations are in place.
What i have noticed is that if i dont add the javscript function to the save button no post back occurs and the validations work as they are supposed to but then i cant get the confirmation message.
But if i use JavaScript function , the page posts back and on refreshing the validations show up .
One solution i came up with was to remove "Return" from "Return OnSaveClick()"
But in this case if i click "Cancel" the post back occurs.
|
|
|
|
|
Make sure that your required field validators are ClinetScriptEnable=true
BTW what validation are firing after post back
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Yes i have done that still the post back occurs.
Required Field Validators are firing after post back....which fire before post back in case java script function is not added
|
|
|
|
|
Yes when you are attaching the javascript to button then validations at the client side will not fire as you are returning the bool from the function because of that validation of client side are not firing you can check by just by commenting all return from javascript function and from registration in PageLoad. I think its clear now ?
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
If i remove return it will post back when i click cancel in the Confirm Prompt.
|
|
|
|
|
If you use javascript then validator controls will not file.
Best Regard
Pathan
---------------------------------------------------
|
|
|
|
|
remove the required field validator and add the javascript validation that will check the text box are empty or what ? i don't have proper sloution right now but this is another way to do it .............
but whats the problem if the page is getting post back and then displaying error message ...........
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Thanx for the help
I guess i will have to use java script validations
|
|
|
|
|
My pleasure
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Can anyone tell one which validator control I have to use to check for
some controls which should accept alphabets only,
Some controls which should accept numbers only,
Some controls which should accept alphanum only,
Some controls which should accept floating type only,
Please tell me which validator I have to use for the above requirement and how it should be used in ASP.Net 2.0 in Visual Studio 2005
Priya
|
|
|
|
|
For this one you can use regular Expression validator for that you need to provide regular expression . Search for regular expresion for different things
Thanks and Regards
Sandeep
If If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Hope this could be of some use to you parameter inside search() statement are few regular expression which you can use.
Validations using Search () Method
1. search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) :- E-Mail Field.
2. search(/^\w+((-\w+))+$/) :- Matches the occurrence of only hyphen (-) between alphanumeric values.
Eg :- Only comm-it, shujaat-khan etc. are valid only between two words.
3. search(/^\w+((\.\w+))+$/) :- Matches the occurrence of only Fullstop (.) between alphanumeric values.
Eg :- Only comm.it, shujaat.khan etc.
4. search(/^\w+((_\w+))+$/) :- Matches the occurrence of only Underscore (_) between alphanumeric values.
Eg :- Only comm_it, shujaat_khan etc.
5. search(/^\w+((\W\w+))+$/) :- Matches the occurrence of only Blank Space between alphanumeric values.
Eg :- Only comm it 123, shujaat ullah khan etc.
6. search(/^[0-9]+\.+([0-9]+)+$/) :- Matches the occurrence of only decimal values.
Eg :- Only 22.200, 39.9786 etc.
7. search(/^[0-9]+$/) :- Matches the occurrence of only numeric values.
Eg :- Only 22200, 399786 etc.
8. search(/^[A-Za-z]+$/) :- Matches the occurrence of only Alphabets values.
Eg :- Only shujaat, commit etc.
9. search(/^([A-Za-z]+[A-Za-z0-9]+$)|^[A-Za-z]+$/) :- Matches the occurrence of an Alphabet in beginning and the
others being alphanumeric values.
Eg :- Only shujaat, commit etc.
10. search(/^[A-Za-z]+[\WA-Za-z]+$/):- Matches the occurrence of only Spaces between alphabets.
Eg :- Only comm it, shujaat khan etc.
Shujaat
|
|
|
|
|
Where I have to use this Search method and how I have to use this search method.Since Iam new to this please explain me
Priya
|
|
|
|
|
If you are writing a javascipt for validation you can use search method.
as if variale xyz contain the text to be validates then use
xyz.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)
However if you are using vaildation control then just copy the regular expression in search method which suits your requirement and set it in validation control.
Shujaat
|
|
|
|
|
As the subject reveals, I'm trying to access an ImageField programmatically in order to set the image according to the business object.
In the RowDataBound event handler, I have:
<br />
protected void MessagesGridView_RowDataBound(object sender, GridViewRowEventArgs e)<br />
{ <br />
if (e.Row.RowType == DataControlRowType.DataRow)<br />
{<br />
ImageField theImage = (ImageField)e.Row.Cells[0].Controls[0];<br />
But I get a "[...] Cannot convert type 'System.Web.UI.Control' to 'System.Web.UI.WebControls.ImageField' [...]"
I've searched like mad, but I can't see what I'm doing wrong.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
Please try this........
ImageField theImage = (ImageField)e.Row.Cells[0].FindControl("imageFieldID");
Parwej Ahamad
g.parwez@gmail.com
|
|
|
|
|
Thanks for your suggestions; unfortunately it gives the same compiler error.
I "solved" the issue by simply adding an Image control to the ImageField's cell's control collection. Not very clean, but it works.
"When you have made evil the means of survival, do not expect men to remain good. Do not expect them to stay moral and lose their lives for the purpose of becoming the fodder of the immoral. Do not expect them to produce, when production is punished and looting rewarded. Do not ask, `Who is destroying the world?' You are."
-Atlas Shrugged, Ayn Rand
|
|
|
|
|
g'day folks,
i'm having a small issue with regards to custom event handlers in my web service. I'm trying to create a custom event handler whose purpose is to display messages on the web form as a particular method is executed via the web service. For instance, lets assume that the web method generates a report from a database then my eventhandler would update on the web form indicating which aspects of the report has been generated.
Initially I thought let's do it the standard way as you would in a standard console application as follows:
public delegate void ReportGenerationProgressEventHandler(string x);
public event ReportGenerationProgressEventHandler myReportGenerationHandler;
The above can be instantiated as follows:
myReportGenerationHandler+= new ReportGenerationProgressEventHandler (Service_myReportGenerationHandler);
In my webservice if I just declare the delegate and event types as above. Then instantiate an object of my webservice in the webform I do not get an option to create my report progress eventhandler via intellisense.
I have tried google but most disscusions tends to be focused on custom events for custom controls unless I go write a custom control which I think will not be appropriate in my case at all.
Is there an alternative method of achieving the same result in asp.net ?
thanks
edit: mistake in code
|
|
|
|
|
Just to answer my own question and for anyone else's benefit.
Well it seems that web services in .net doesnt support eventing even though there is a specification,[^] , from the W3C committee that web services should support eventing. The only other option will be to use WCF however platform compatability will be an issue.
|
|
|
|
|
Hi.
I'm using ASP.NET 2.0 and MS SQL Server 2005 environment. I'm developing an aspx page which is using DetailsView to insert data.
There are several TemplateFields are located at the DetailsView control. These Template fields containing TextBox and DropDownlList controls and I'm passing values of these controls using %Bind% syntax:
<asp:DetailsView ID="dvCity" runat="server" AutoGenerateRows="False" DataKeyNames="Id"
DataSourceID="sdsCity" DefaultMode="Insert" OnItemInserted="dvCity_ItemInserted">
<Fields>
<asp:BoundField DataField="Id" HeaderText="Id" InsertVisible="False" ReadOnly="True"
SortExpression="Id" Visible="False" />
<asp:TemplateField HeaderText="Name">
<InsertItemTemplate>
<asp:TextBox ID="txbName" runat="server" Text='<%# Bind("Name") %>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvName" runat="server" ControlToValidate="txbName" SetFocusOnError="true"
Display="Dynamic" ErrorMessage="You must specify a non-blank value for Name.">*</asp:RequiredFieldValidator>
</InsertItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="RegionId" HeaderText="RegionId" SortExpression="RegionId"
Visible="False" />
<asp:TemplateField HeaderText="Region">
<InsertItemTemplate>
<asp:DropDownList ID="ddlRegion" runat="server" DataSourceID="sdsRegion" DataTextField="Name"
DataValueField="Id" SelectedValue='<%# Bind("RegionId") %>'>
</asp:DropDownList>
</InsertItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
DataSource for the DetailsView is the SqlDataSource which is using StoredProcedures to insert data into Database.
Some parts of business logic are located in the T-SQL code of the StoredProcedure and in case of any error I'm throwing exception from T-SQL using RAISE_ERROR method.
In the aspx.cs, OnItemInserted event of the DetailsView I've implemented following code for exception processing:
protected void dvCity_ItemInserted(object sender, DetailsViewInsertedEventArgs e)
{
if (e.Exception != null)
throw e.Exception;
else
Response.Redirect("City.aspx");
}
When there is no error during StoredProcedure execution everything is works fine.
When my StoredProcedure raises any exception and this exception was handled by my handler user sees the AJAX popup and clicks OK.
Then popup closes, user edits values in DetailsView controls, clicks Save again BUT I got another exception saying that ((TextBox)dvCity.FindControl("txtName")) is NULL. The same is for DropDownList.
It seems to me that DetailsView loses databinding after an exception occurs during Insert/Update operation.
<b>Does anyone can help me how to handle or re-throw exception without DetailsView unbind?</b>
http://www.jetideas.com
|
|
|
|