Showing posts with label box. Show all posts
Showing posts with label box. Show all posts

Wednesday, March 28, 2012

postback happens even when validators show error

Hi,

I am using updatepanel in my code. I give a picture of a part of my code.

Now i have a text box with some validators on it ( required field validator and regular expression validator).

I have a save button which saves the content of the text box .

The textbox is withing the update panel and the save button is outside the update panel.

Now when a wrong iput is entered , on tab out the validator shows the error messgae but on clicking th ebutton , a post back happens. in general case where a update panel is not used the button postback event doesnt happen until the validators return true.

Could you help me on this.

Regards,

Sama

any resolution to this problem yet?

this really needs to be fixed


I also have come across this problem. I have three validators on the footer row of a gridview which is in an UpdatePanel. I use the footer for insertion of new records. When I click 'Insert', the validators fire ok and I get the red asterisks and all but it still posts back. When I take the whole thing out of the UpdatePanel it works as it's supposed to, preventing the postback if no data is entered.

I am using the latest version of Atlas.

Has anyone a solution to this and is it going to be fixed in a future ctp?

Regards,

Andy.


I just investigated further and found the following strage behaviour:

When my page first loads, the gridview is populated with data. The footer is not visible on the gridview as I set ShowFooter() to false by default. There is a button at the bottom of the page "Add Item". This posts back and sets the ShowFooter() to true so that the insert line appears. In this scenario, when the user leaves the new text fields blank, the validator fires but the page still posts back - WRONG.

If I show the footer by default when the page loads, the validators fire correctly and prevent the postback - CORRECT.

Can anyone shed any light on this, I don't want to have my insert line shown by default.

Andy.


bump...

Saturday, March 24, 2012

Problem getting AutoComplete Extender to work

Hi I just want to get the autocomplete extender to work with a text box and I'm having trouble getting it to work. It seems like the service isnt being called or that the control isnt working. Compiles fine and no errors in IE when its opened

Heres the code.

AJAXServices.asmx

<%@dotnet.itags.org. WebService Language="VB" CodeBehind="~/App_Code/AjaxServices.vb" Class="AjaxServices" %>

AJAXServices.vb

Imports DataAccess
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports System.Data
Imports System.Data.Common
Imports System.Data.SqlClient
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AjaxServices
Inherits System.Web.Services.WebService

<WebMethod()> _
Public Function GetModelList(ByVal prefixText As String, ByVal count As Integer) As String()
Dim strSQL As String
Dim titleArList As New List(Of String)
Dim dtModels As DataTable

strSQL = "SELECT DISTINCT Alias FROM LaptopDescTier WHERE Alias LIKE @dotnet.itags.org.Model"
strSQL = strSQL.Replace("@dotnet.itags.org.Model", FormatSQLInfo(prefixText & "%"))
dtModels = ReturnTable(strSQL)

For Each drModel As DataRow In dtModels.Rows
titleArList.Add(drModel("Alias").ToString)
Next

Return titleArList.ToArray()

End Function

End Class

UpdateLaptopModels.aspx

<%@dotnet.itags.org. Page AutoEventWireup="false" CodeFile="UpdateLaptopModels.aspx.vb" Inherits="UpdateLaptopModels"
Language="VB" MaintainScrollPositionOnPostback="true" MasterPageFile="~/Admin.master"
Title=":: Laptop Management System ~ Administration ::" %
<asp:Content ID="Content1" runat="Server" ContentPlaceHolderID="cphAdmin">
<asp:ScriptManager ID="ScriptManager" runat="server">
</asp:ScriptManager>
<div class="Container">
<h2>
Update Laptops Models</h2>
<div class="StandardBreakSpace">
</div>
<asp:TextBox ID="txtAlias" runat="server"></asp:TextBox>
<ajaxToolkit:AutoCompleteExtender ID="aceAlias" runat="server" CompletionInterval="1000"
CompletionSetCount="12" EnableCaching="true" MinimumPrefixLength="1" ServiceMethod="GetModelList" Enabled="true"
ServicePath="Services/AjaxServices.asmx" TargetControlID="txtAlias">
</ajaxToolkit:AutoCompleteExtender>
</div>
</asp:Content>

Web.config

<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<appSettings>

</appSettings>
<connectionStrings>

</connectionStrings>
<system.web>
<pages>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
</pages>
<identity impersonate="true"/>
<authentication mode="Windows"/>
<customErrors mode="RemoteOnly" defaultRedirect="Error.htm">
<error statusCode="403" redirect="NoAccess.htm"/>
<error statusCode="404" redirect="FileNotFound.htm"/>
</customErrors>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<profile>
<properties>
<add name="SearchTerms" type="System.Collections.Specialized.StringCollection" serializeAs="Xml"/>
</properties>
</profile>
</system.web>
<system.web.extensions>
<scripting>
<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and
writeAccessProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
-->
</webServices>
<!--
<scriptResourceHandler enableCompression="true" enableCaching="true" />
-->
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration


Once I get this working I want to use the text box and extender in a itemtemplate in a gridview. Will that work?

Thanks for looking into this and all suggestions are welcome!

Dude, found it!!!

change this...


<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AjaxServices
Inherits System.Web.Services.WebService

End Class

TO

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
Public Class AjaxServices
Inherits System.Web.Services.WebService

End Class


I'll give this a try at work tomorrow. I just gave up. If this works, you are truly the man!Wink



If not, you can try this:

http://forums.asp.net/thread/1563579.aspx

I had trouble getting autocomplete in vb to work, and listed a few things I noticed there.

(Using in-page methods, no .asmx)


Jared,

Unfortunately even this doesnt get it to fire. I wonder if you could put together a quick sample that fires in VB to use as a template.


I posted my working code (simplified) on the thread i linked above...

FYI - I've been banging my head all day, and this worked for me. Is there something to be done to get around the need to remember to make this change? This was a pre-exising ASP.NET app to which I'm adding AJAX functionality.

Thanks!

rojay12:

Dude, found it!!!

change this...


<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class AjaxServices
Inherits System.Web.Services.WebService

End Class

TO

<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<System.Web.Script.Services.ScriptService()> _
Public Class AjaxServices
Inherits System.Web.Services.WebService

End Class

Wednesday, March 21, 2012

problem in serverside validation

hi to all

i have few text box and button in updatepanel . Now i want to do asynchronously postback on button click and for that

i have did my all validation on serverside as follow

CS code

1protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
2 {
3
45try6 {
7if (cmbAdvertisementType.SelectedValue =="0")
8 {
9throw new Exception("You must select a Advertisement Style.");
10 }
1112if (cmbKiosk.SelectedValue =="0")
13 {
14throw new Exception("You must select a Server.");
15 }
1617if (string.IsNullOrEmpty(txtFromDate.Text))
18 {
19throw new Exception("You must supply a Start Date.");
20 }
2122if (string.IsNullOrEmpty(txtToDate.Text))
23 {
24throw new Exception("You must supply an EndDate.");
25 }
2627
2829 System.Threading.Thread.Sleep(4000);
30 DataTable parameterTable = objdt.GetTable();
31 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.StarDate", SqlDbType.DateTime, 30, Convert.ToDateTime(txtFromDate.Text, format), ParameterDirection.Input));
32 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.EndDate", SqlDbType.DateTime, 30, Convert.ToDateTime(txtToDate.Text, format), ParameterDirection.Input));
33 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.ServerId", SqlDbType.Int, 4, Convert.ToInt32(cmbKiosk.SelectedValue), ParameterDirection.Input));
34 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.AdvertiseId", SqlDbType.Int, 4, Convert.ToInt32(cmbAdvertisementType.SelectedValue), ParameterDirection.Input));
35 parameterTable.Rows.Add(objdt.CreateRow("@dotnet.itags.org.Mode", SqlDbType.VarChar, 10,"Dataset", ParameterDirection.Input));
36 ds = objDB.GetDSByProcedure("SP_CheckAvailibily", parameterTable);
37 parameterTable.Rows.Clear();
38 gvSlotAvailibily.DataSource = ds;
39 gvSlotAvailibily.DataBind();
40 AccordionView.SelectedIndex = 1;
41 UpdatePanel2.UpdateMode = System.Web.UI.UpdatePanelUpdateMode.Always;
42 UpdatePanel2.ChildrenAsTriggers =true;
43 }
44catch (Exception ex)
45 {
4647 sendPopupMessage(ex.Message);
48 }
49
50 }
5152
5354private void sendPopupMessage(string Message)
55 {
56 ScriptManager.RegisterStartupScript(this,this.GetType(),"key","<script language='Javascript'> alert('" + Message +"'); </script>",false);
57 }

aspx code

1<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="AdvertiseBook.aspx.cs" Inherits="AdvertiseBook" Title="Advertisement Booking" %>2<%@dotnet.itags.org. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit"%>3<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">4<aspajax:ScriptManager ID="ScriptManager2" EnablePageMethods="True" EnablePartialRendering="true" EnableScriptLocalization="true" runat="server">5 <Scripts>6 <aspajax:ScriptReference Path="AdvertiseBook.js" />78 </Scripts>910 <Services>11 <aspajax:ServiceReference Path="WebService.asmx" />12 </Services>1314 </aspajax:ScriptManager>1516 <div id="lmenucontainer">17 <div class="menuitem" id="m1" name="m1">18 <asp:LinkButton runat="server" Text="Tabular View" ID="lnkView" onmouseover="lmenuover(m1.id);" onmouseout="lmenuout(m1.id);" OnClick="lnkView_Click"></asp:LinkButton>19 </div>20 <div class="menuitem" id="m2" name="m2">21 <asp:LinkButton runat="server" Text="Add New Agency" ID="lnkaddAgency" onmouseover="lmenuover(m2.id);" onmouseout="lmenuout(m2.id);" OnClick="lnkaddAgency_Click"></asp:LinkButton>22 </div>23 <div id="lm5" onmouseover="lmenuover('lm5');" class="menuitem bottomborder" onmouseout="lmenuout('lm5');" name="lm5">24 <asp:LinkButton id="lnkNewAd" onmouseover="lmenuover('lm5');" onmouseout="lmenuout('lm5');" runat="server" Text="New Advertisement" OnClick="lnkNewAd_Click"></asp:LinkButton>25 </div>26 </div><!-- lmenucontainer closing -->27 <aspajax:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" ChildrenAsTriggers="False" runat="server">28 <ContentTemplate>2930 <div id="disparea" >31 <asp:Panel ID="pnlTableView" runat="server" Visible="false">32 <ajaxToolkit:Accordion ID="AccordionView" runat="server" SelectedIndex="0"33 HeaderCssClass="accordionHeader" HeaderSelectedCssClass="accordionHeaderSelected"34 ContentCssClass="accordionContent" FadeTransitions="false" FramesPerSecond="40"35 TransitionDuration="250" AutoSize="None" RequireOpenedPane="false" SuppressHeaderPostbacks="true">36 <Panes>37 <ajaxToolkit:AccordionPane ID="AccordionPane5" runat="server">38 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Check Availibility of Slot</a></Header>39 <Content>40 <table>41 <tr>42 <td>43 <asp:Label ID="lblAdvertisementType" runat="server" Text="Advertisement Type" ></asp:Label>44 </td>45 <td>46 <asp:DropDownList ID="cmbAdvertisementType" runat="server" OnLoad="cmbAdvertisementType_Load">47 </asp:DropDownList>48 </td>49 </tr>50 <tr>51 <td>52 <asp:Label ID="lblKiosk" runat="server" Text="Kiosk Name" ></asp:Label>53 </td>54 <td>55 <asp:DropDownList ID="cmbKiosk" CssClass="cmbborder" runat="server" OnLoad="cmbKiosk_Load" ></asp:DropDownList>56 </td>57 </tr>58 <tr>59 <td >60 <asp:Label ID="lblFrom" runat="server" Text="From" ></asp:Label>   61 </td><td>62 <asp:TextBox ID="txtFromDate" EnableViewState="true" runat="server"></asp:TextBox>63 <asp:Image ID="imgFromDate" ImageUrl="~/images/Calendar_scheduleHS.png" runat="server" />64 <ajaxToolkit:CalendarExtender ID="CalendarExtender1" Format="dd/MM/yyyy" Animated="true"65 PopupButtonID="imgFromDate" TargetControlID="txtFromDate" EnableViewState="true" runat="server">66 </ajaxToolkit:CalendarExtender>67 </td></tr>68 <tr><td>69 <asp:Label ID="lblTo" runat="server" Text="To" ></asp:Label>70 </td><td>71 <asp:TextBox ID="txtToDate" EnableViewState="true" runat="server"></asp:TextBox>72 <asp:Image ID="imgToDate" ImageUrl="~/images/Calendar_scheduleHS.png" runat="server" />73 <ajaxToolkit:CalendarExtender ID="CalendarExtender2" Format="dd/MM/yyyy" Animated="true"74 PopupButtonID="imgToDate" TargetControlID="txtToDate" EnableViewState="true" runat="server">75 </ajaxToolkit:CalendarExtender>76 </td>77 </tr>78 <tr>79 <td colspan="2" align="center">80 <asp:ImageButton ImageUrl="~/images/submit.gif" ID="btnSubmit" runat="server" OnClientClick="CheckDateValidation();" OnClick="btnSubmit_Click" />8182 </td>83 </tr>848586 </table>87 </Content>88 </ajaxToolkit:AccordionPane>89 <ajaxToolkit:AccordionPane ID="AccordionPane6" runat="server">90 <Header><a href="http://links.10026.com/?link=" class="accordionLink">Tabular View of Slot Allocation</a></Header>91 <Content>92 <asp:GridView AutoGenerateColumns="false" AllowPaging="true" ShowFooter="true" ShowHeader="true" ID="gvSlotAvailibily" runat="server" OnPageIndexChanging="gvSlotAvailibily_PageIndexChanging" >93 <Columns>94 <asp:BoundField DataField="DATE" DataFormatString="{0:MM-dd-yyyy}" HeaderText="Date" />95 <asp:BoundField DataField="Available" HeaderText="Available Slot" ItemStyle-HorizontalAlign="Center" />96 <asp:BoundField DataField="TempBookSlot" HeaderText="Temp Booked Slot" ItemStyle-HorizontalAlign="Center" />97 <asp:BoundField DataField="BookedSlot" HeaderText="Booked Slot" ItemStyle-HorizontalAlign="Center" />98 <asp:BoundField DataField="TotalSlot" HeaderText="Total Slot" ItemStyle-HorizontalAlign="Center" />99 </Columns>100 </asp:GridView>101102 </Content>103 </ajaxToolkit:AccordionPane>104 </Panes>105 </ajaxToolkit:Accordion>106107108 </asp:Panel>109 </div>110 </ContentTemplate>111 <Triggers>112 <aspajax:AsyncPostBackTrigger ControlID="lnkaddAgency" EventName="Click" />113 <aspajax:AsyncPostBackTrigger ControlID="lnkNewAd" EventName="Click" />114 <aspajax:AsyncPostBackTrigger ControlID="lnkView" EventName="Click" />115 <aspajax:AsyncPostBackTrigger ControlID="btnadvertiseSubmit" EventName="Click" />116 </Triggers>117118119 </aspajax:UpdatePanel>

but it not working properly

Both should work

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "<script language='Javascript'> alert('" + Message + "'); </script>", false);

ScriptManager.RegisterStartupScript(this, this.GetType(), "key", " alert('" + Message + "'); ", true);


here problem is not with sendPopupMessage()

actully after 1st validation it doesn't get submit



http://www.asp.net/AJAX/Documentation/Live/mref/O_T_System_Web_UI_ScriptManager_RegisterStartupScript.aspx

Better way you use validators..

But see for more details

Validation controls, which includes theBaseCompareValidator,BaseValidator,CompareValidator,CustomValidator,RangeValidator,RegularExpressionValidator,RequiredFieldValidator, andValidationSummary control are not compatible with UpdatePanel

See it here

http://weblogs.asp.net/scottgu/archive/2007/01/25/links-to-asp-net-ajax-1-0-resources-and-answers-to-some-common-questions.aspx

You can downlaod compatible ersion of validators from here

http://blogs.msdn.com/mattgi/archive/2007/01/23/asp-net-ajax-validators.aspx

Problem in Showing Remainder in asp.net

Hi everybody

I am trying to show remainder to user who logged in the site.Whatever task he have to do is just shown in the alert box or popup window in a particular time.I used atlas timercontrol.The coding is

<form id="form1" runat="server">

<input type='text' id='myText' runat="server" visible="false" />
<div>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
<asp:ListItem>a</asp:ListItem>
<asp:ListItem>s</asp:ListItem>
<asp:ListItem>g</asp:ListItem>
</asp:DropDownList>
<cc1:ScriptManager ID="ScriptManager1" runat="server">
</cc1:ScriptManager>

</div>
<cc2:TimerControl ID="TimerControl1" runat="server" Interval="1000" OnTick="TimerControl1_Tick">
</cc2:TimerControl>
</form>

protected void TimerControl1_Tick(object sender, EventArgs e)
{
string qry = "select * from Task_det where alertstatus='y'";
DataSet ds = new DataSet();
ds = Newway.getTable(qry);
if (ds.Tables[0].Rows.Count != 0)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertDt"].ToString()) == DateTime.Parse(System.DateTime.Now.Date.ToString()))
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Hour == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Hour)
{
if (DateTime.Parse(ds.Tables[0].Rows[0]["AlertTime"].ToString()).Minute == DateTime.Parse(System.DateTime.Now.TimeOfDay.ToString()).Minute)
{

TimerControl1.Enabled = true;
// Response.Write("<script language='javascript'>alert('hai');</script>");
myText.Value = "Task:" + ds.Tables[0].Rows[0]["TaskTitle"].ToString();

//Response.Write("<script language='javascript'>var myTextField = document.getElementById('myText');alert(myTextField .value);</script>");
Response.Write("<script language='javascript'>window.open('showtask.aspx?Task="+ ds.Tables[0].Rows[0]["TaskTitle"].ToString().Trim() + "','REMAINDER','height=100,width=200');</script>");

TimerControl1.Interval = 60000;

}

else
{
TimerControl1.Interval = 30000;
}
}

}
}

Here i want to hide this page from the user timercontrol will start checking after the login process.But it should be behind the screen.Only alert popupwindow (showtask.aspx) is shown in particular.Is there any alternative sollution or extend this code..Please help.

Thanks& Regards

Jhanani.R

Hi Jhanani,

What do you mean by hiding the page from the user?
I can't get your point very well.
Looking forward to your reply.

Hello,

What you can do is, use WebService.

For example, the user logs in and goes straight to mypage.aspx; once he/she is at the page, you can have a javascript function running behind the background; the function checks the webservice, which check the database to see if the user has any remainder (task), if the webservice returns true (meaning there are remainders (tasks)), then cancel the loop and use window.open to open showtasks.aspx page of yours. If there's none, then continue looping and checking every 20 seconds or so.

I would use SetTimeOut, don't use for loop or while loop, or any loop... =)


I mean to say i dont want a separate page for clock tick it will be common for all the pages am using in project.Any pages i can navigate but the clock should

tick and check the matching time and give alert.I have completed this using atlas control.But my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.

Do u have any idea please tell

Jhanani


So here is your situation:

You have a page will continualy check if there is an event for the current user, if so, a remider will show. And you intend to hide this page from the user because it actually doesn't have any visual component.

I think you can use amaster page. It works as the template of all pages in your application.

Move the code above into it so that all pages will have this function.

JananiSharma:

my friends are suggesting to do it with thread and log file.log file to hold the clock tick time.

The customer will use a browser to visit your application, but you can't start a thread on the client via the customer's browser. If you application is windows based, it's a good idea, but not for a web based application.


ya i used atlas timer control in master page and call alert popup if event occurs in the particular time.But my team leader asked me to try in windows service.Is it possible


Yes, it's a feasible solution.

You can start a thread in the windows service to monitor if there is any reminder to show. But it's necessory to install the windows service on each machine.


Will you give one example.

And in timer control when it shows alert message that time the page which is running get changes in styles .For me font size is changing when the alert message appears.But for the next clock tick it again come to previous state.Please tell me solution for this.

Thanks&Regards,

Jhanani.R


Please follow this tutorial for how to create a windows service: http://msdn2.microsoft.com/en-us/library/aa984464(VS.71).aspx

Also note that now your application isn't a web/browser based application, you are doing windows programming now.

For more information about Windows service, please read this: http://msdn2.microsoft.com/en-us/library/d56de412(VS.80).aspx


Raymond,

If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?

I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.

And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...


Raymond, clear me up if i'm talking nonsense, thanks ... =)


WishStar99:

Raymond,

If the poster uses a windows service to track the tasks from the database, how does the windows service communicate with the user(s) from the web app? Does the web app have to start the communcation with the windows service first?

I am asking because I don't know; and also i have a feeling that using windows service will create more works. May be the poster (forgot what the name is) should talk with the team leader again.

And installing the service on each system is not a good idea either. What if it's a public system? Plus, you need to program to when the windows service should run and when it should not. This is when you need to use ActiveX. Or is there an easier way, or am I over thinking? I just give my opinion so that the poster should not use windows service if i'm correct ...


Raymond, clear me up if i'm talking nonsense, thanks ... =)

Hi,

Yes, as you've mentioned, those problems do exist.

To implement the reminder with Timer on the web page is a solution, but not good enough. The thing is that if I want to receive reminder, I have to keep the browser open. While windows service can keep running without any UI.

For the windows service here, it doesn't need to communicate with the web app. It's a separate application.


Sorry i forgot to say that am developing project in web application.I want to know timer control in windows service.Thats y i asked.Will you please tell y the styles are changing after the alert message

Thanks& Regards,

Jhanani.R


Sorry i forgot to say that am doing project in web application.But i wanna know the windows service .Thats y i asked.Please tell y font changes during alert message.

Thanks&Regards,

Jhanani.R


Raymond,

I know it's a seperate application. My concern is, how does the user from the web application knows that there's a new task for him or her? Does the web app page have to communicate with the windows service somehow? Here's what I understand so far:

You have a windows service timer which detects if there's any tasks for a certain user or not, if yes, then what will happen? How does the windows service notify the user from the web application?

Raymond, again, i'm not debating with you, but i want to know so i can learn from it =) thanks ....


Okay, forget it ... i'll leave you alone. LOL.

I'll check back when the problem is solved.


JananiSharma ... let us know what's the solution is ... thanks ...