|
I have 10 textboxes and now I have to validate them using Required Field Validator. Is there any way to validate them without using 10 required field validators(i.e. only using one). Or are there any better ideas.
|
|
|
|
|
|
Hi all,
I have an usercontrol where i gave a radiobutton list.(rblTest)
I am using this usercontrol in my aspx page.
RadioButtonList rblTest= (System.Web.UI.WebControls.RadioButtonList)myControl1.FindControl("rblTest");<br />
I need to handle onselectindexchanged method of radiobutton list in aspx page.
How to do that.
Plz give ur suggestions.
Thanks in advance
cheers
sangeet
|
|
|
|
|
To do that you must first declare in your "hosting" aspx page a procedure which will handle an event:
public void RadioButtonIndexChangedProc(object sender, System.EventArgs e)<br />
{<br />
RadioButtonList rbl = (RadioButtonList) sender;<br />
}
Next in the user control, in the SelectedIndexChange event call that procedure:
private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
WebForm1 page = (WebForm1) Page;<br />
page.RadioButtonIndexChangedProc(sender, e);<br />
}
As you can see, you can access your hosting aspx page by using Page object, and by casting it to appropriate type (class of your hosting page, in my case WebForm1 ) you have access to all public class members.
In case of reusing an usercontrol on diffrent web pages think about implementing one base class or implementing an Interface which will handle RadioButtonIndexChange by every class which uses your usercontrol.
--
Mariusz 'mAv' Wójcik
master e-software engineer
|
|
|
|
|
OKi,
in addition to my above answer, there is a solution which uses interface.
First, we implement an Interface:
public interface IRadioButtonListEvent<br />
{<br />
void RadioButtonIndexChangedProc(object sender, System.EventArgs e);<br />
}
As you can see, our interface implements just one method, which will be called whenever selected item index changes.
Now, in the User Control, RadioButtonList1_SelectedIndexChanged should look like this:
private void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)<br />
{<br />
IRadioButtonListEvent iPage = (IRadioButtonListEvent) Page;<br />
iPage.RadioButtonIndexChangedProc(sender, e);<br />
}<br />
And finally, code for hosting web page. As i mentioned above, page must implement an IRadioButtonListEvent interface.
public class WebForm1 : System.Web.UI.Page, IRadioButtonListEvent<br />
...<br />
<br />
public void RadioButtonIndexChangedProc(object sender, System.EventArgs e)<br />
{<br />
RadioButtonList rbl = (RadioButtonList) sender;<br />
}
--
Mariusz 'mAv' Wójcik
master e-software engineer
|
|
|
|
|
Both of your solutions couple the user control and page together very strongly, which limits the flexiblity and reuse.
only two letters away from being an asset
|
|
|
|
|
Handle the onselectindexchanged event in your user control and create an event in your user control that any page can subscribe to that reflects the onselectindexchanged event. A technique called event bubbling.
http://www.odetocode.com/Articles/94.aspx[^]
only two letters away from being an asset
|
|
|
|
|
Hi in my form using crystalreportviewer i dispalyed my crystal form..,
And in print button i said this code...,
report.SetDatabaseLogon("sa", "pwd", "server", "Databasename")
report.PrintToPrinter(1, False, 0, 0)
If i click the print button process is going on..,
But in between process will stop its not printing the page...,
Plz any one solve my probs...,
Magi
|
|
|
|
|
how to create master detail for ADD/EDIT/Delete/Display
master data
(company code , name, mapcode)
- text box
detail data
( company detail code, fin_statdate, fin_enddate, process_status, companycode)
--grid view
vijaya
vijaya
|
|
|
|
|
If you are using 2.0 there is a DetailsView control that can be bound to the master's (possibly a grid view control) data source.
only two letters away from being an asset
|
|
|
|
|
Check out that ASP.NET Data Tutorial series on the asp.net site, they'll show you what you want to do.
|
|
|
|
|
i am attempting to write the cookies for a landing page.
i have used the following code to analyse the presence of cookies, but dont know how to write the cookie for the page loading.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Request.Cookies("Landing") Is Nothing Then
'if the name cookie does not exist ask user to enter name
Response.Redirect("landing.aspx")
Else
'if cookies already exist then show landing page
Response.Redirect("tMN_index.aspx")
End If
this seems to work in terms of directing to the landing page.. just need the cookie help....
i basically want the landing page to appear if the cookie isnt present, and then the landing page to generate the cookie if not present.
thank you
John Michael Kinsella
kinsellajohn@hotmail.com
|
|
|
|
|
As I understand, you want to know how to create a new cookie. Below is a simple example how to do that. Depends on your needs, set appropriate properties of System.Web.HttpCookie object.
Basically you simply add a new cookie object into Response.Cookies collection and that's all. Using Respose.Cookies class you can also remove or change any cookie your application creates.
Dim cookie As System.Web.HttpCookie
Dim cookieName As String
Dim cookieValue As String
cookie = New System.Web.HttpCookie(cookieName, cookieValue)
Response.Cookies.Add(cookie)
--
Mariusz 'mAv' Wójcik
master e-software engineer
|
|
|
|
|
Hi all,
i have to validate for a textbox field in ASP.NET 2.0 using C#.
the requirement is that the textfield should accept only numbers.
i want the field such tat it should accept number..... any number of any length.....
please send me the code for the same......
the regular expression validator with the validation expression
ValidationExpression="[0-9]"
accepts only a single digit number.........
how do i make it accept any number!!!!!!!
Thanks,
Ramesh
|
|
|
|
|
Well, you should change the ValidationExpression to accept more than one character. Also, decide whether you will accept +/- sign before the number, decimal point etc. Than build proper regular expression and that's it.
I strongly recommend to read a little about "creating regular expression" on the MSDN.
And to make it works, and accept any number of digits modify ValidationExpression to "[0-9]*".
--
Mariusz 'mAv' Wójcik
master e-software engineer
|
|
|
|
|
include * in your validation expression either at the begining or at the end.
|
|
|
|
|
hello ramesh,
try to use the following code in Javascript
function CkhInte(obj)
{
if (isNaN(obj.value))
{
alert('Please enter only digits');
return false;
}
}
hope it helps,
please rate this message if useful,
best regards,
koolprasad2003
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
Nice, but when user turn off javascript in browser it will allow him to enter incorrect input. It's necessary to do the same validation on server. ASP.NET validators do both for you.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
ValidationExpression="^\d+$"
the above expression is a regular expression validator to validate for numbers......
|
|
|
|
|
>hi i currently have an dataview which have some data. it is link to an dropdownlist which contain the type.
i have added the ALL option to the dropdownlist however i cant get it to work.
could anyone help me or giv option/suggestion i am really stuck...
(what i want is to have a dropdownlist which would filter the type of data i have in the gridview <==this i have achieve but i cant seem to add an ALL button to view all record)
also if possible i would like to have the dropdownlist retain the selected option retain after the datagrid have change
below is some part of my code which i think is vital currently i have achieve the filter of type however i cant seem to have the ALL option working..
<br />
protected void Page_Load(object sender, EventArgs e)<br />
<br />
{<br />
<br />
if (!IsPostBack)<br />
<br />
{<br />
<br />
SqlConnection conn = new SqlConnection((ConfigurationManager.ConnectionStrings["ASPNETDBConnectionString1"]).ToString());<br />
<br />
SqlCommand cmd = new SqlCommand("SELECT DISTINCT Type FROM Product", conn);<br />
<br />
try<br />
<br />
{<br />
<br />
conn.Open();<br />
<br />
SqlDataReader dr = cmd.ExecuteReader();<br />
<br />
ddltype.Items.Add("All");<br />
<br />
<br />
while (dr.Read())<br />
<br />
{<br />
<br />
ddltype.Items.Add(dr.GetValue(0).ToString());<br />
<br />
}<br />
<br />
<br />
}<br />
<br />
catch<br />
<br />
{<br />
<br />
}<br />
<br />
conn.Close();<br />
<br />
}<br />
<br />
else<br />
<br />
{<br />
<br />
<br />
<br />
protected void ddltype_SelectedIndexChanged(object sender, EventArgs e)<br />
<br />
{<br />
<br />
<br />
string pType = ddltype.SelectedItem.Text.ToString();<br />
<br />
<br />
<br />
<br />
Response.Redirect("Product.aspx?Type=" + pType);<br />
<br />
<br />
}<br />
<br />
<br />
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"<br />
<br />
SelectCommand="SELECT [ID], [Name], [quantity], [Pic], [Type], [comment], [desc] FROM [Product]"><br />
<br />
</asp:SqlDataSource>
|
|
|
|
|
hi all,
Could anybody help me to Display MS Excel sheet in ASPX page in Excel format, in such a way that i could modify it and save it back.
Any suggation will be appritiated...
Many Thanks in advance..
Rajnish Kumar
rajnish
|
|
|
|
|
Hope the Article by Gnanandam Gopalan MS EXCEL[^] will help you.
Regards,
Satips.
|
|
|
|
|
First of all thanks alot for providing me your response. The link you sent would have been helped me , but i have to code in ASP.NET 1.1 and the exapmle in the link is for ASP.NET 2.0
I have already tried that link , but i was unable to use that code provided in that link in ASP.NET 1.1.
So if you could help me to do the same in ASP.NET 1.1 that will be very much appritiated..
Thanks and Regards
|
|
|
|
|
I don't think you can do it without help.
I am using Office Write from SoftArtisans.
http://officewriter.softartisans.com/
Their product allows you to easily and quickly read excel values on the server and update Cells in an excel spreadsheet. Also they have an activeX control that you can install on the clients. This activeX control has a "post" function (which can be called from a VBA Macro) that will allow you to post your file to an aspx page. I have been able to implement what you wish to do using the Office Writer. I don't know of any other way you can do this without having the user save the file to disk and then using an html file control to post the file to a server.
|
|
|
|
|
Hi ToddHileHoffer,
Great thanks for your response, i have visit the link that you sent me and it would have been help me if that software would have been available free for me. Could you pls sugges me any such support software for free , as i am a developer in a company and our client is not going to support me financialy for this issue..
So if could provide me such kind of software for free , or you couldl help me in any other manner by providing me any code solution, that will be greatly appritiated....
Thanks and Regards
Rajnish
|
|
|
|