Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Wednesday, March 28, 2012

Postback? how?

in Ajax, how is it possible to do a postback to the server? So for example, i have a modalpopupdialog, and when i click the ok button in it, i want it to postback to the server to process the request or whatever.

how is this done? Currently I have a scriptmanager on the aspx page, and the User control for the modaldialog - now what?

I've noticed something.

If I don't add this custom user control containing ajax in a webpage, then anything on that webpage, the links and button clicks work fine. However if I add this user control with ajax, the button post backs do not fire at all. This is wierd and no idea why. I think it maybe to do with the scriptmanager or the modalpopupextender but not sure

what would the reason be for the click events to the server not being able to fire when we add this user control?


I'm not sure why postbacks don't work with the modal popup, possibley because it was intended to be used with javascript to customise the page?

In any case, you can use the OnOkScript and OnCancelScript properties of the modalpopupextender to fire a postback. You just need to add this line of javascript as the script that is fired when one of those buttons is pressed:

__doPostBack(TargetControl, Argument);


Replace TargetControl with the control id that triggered your postback (if you want a pass the server a different control id you can too) and replace Argument with any argument you want to pass to the server.

Then, in the Page_Load of your page add these lines:

string controlid = Request.Params.Get("__EVENTTARGET");
string argument = Request.Params.Get("__EVENTARGUMENT");

This will allow you to read the arguments you have passed the server, from here you can trigger a function or event handler.



I actually did that before also but made no difference.

Basically.....

If I have a form and place a simple button on it, double click it to make the click event and do something like Response.Write("I was clicked");, it will work fine.

BUT as soon as I add the modalpopupextender, or even infact, add the assembly reference in the aspx file for the ajaxtoolkit, then when i click that button again - nothing happens. no post back is happening. nothing is firing back at all - the page stays the exact same.


any ideas? I'm stuck. I just created a new ajax enabled project on my main home computer, and the same thing happens - when you insert the modalpopupextender, set all the properties etc... it doesnt fire anything (it shows the control of course) but when you take out that control and press say, the button (which is what the OkControlID property is set to in the ajax control), it works and fires the click event.
looks like there seems to be a problem when using base master templates!! How is it possible to use the Base master templates and making ajax do the postback (of the modalpopupextender)

Works great for me – the code…

<asp:LinkButtonID="btnUpload"BackColor="ButtonFace"Font-Size="11px"Font-Underline="false" ForeColor="Black" CssClass="CenterText"BorderStyle="Outset"BorderWidth="1px"

Text="Upload New Photo"runat="server"Width="100px"Visible='<%#IsAdmin%>'>

</asp:LinkButton>

<asp:PanelID="pnlUpload"runat="server" CssClass="modalPopup"style="display:none">

<asp:LabelID="Label5"Font-Size="11px"Font-Bold="true"runat="server"Text="Upload Photo"/>

<asp:LabelID="ErrorLabel"runat="server"Text=""/>

<table>

<tr>

<tdclass="formlabel"align="right">File:</td>

<td><asp:FileUploadID="FileUpload1"runat="server</td>

</tr>

<tr>

<tdclass="formlabel"align="right">Image title:</td>

<td><asp:TextBoxID="imgTitle"runat="server"CssClass="txtfield"/> </td>

</tr>

</table>

<br/>

<tablestyle="margin-left:auto; margin-right:auto;">

<tr>

<tdstyle="width:100px;"align="left">

<asp:ButtonID="btnUploadImg"runat="server"Text="Upload"OnClick="UploadFile_Click"/>

</td>

<tdstyle="width:100px;"align="right">

<asp:ButtonID="btnClose"runat="server"Text="Close"/>

</td>

</tr>

</table>

<br/>

</asp:Panel>

<ajaxToolkit:ModalPopupExtenderID="modalPopup"runat="server"

TargetControlID="btnUpload"

PopupControlID="pnlUpload"

BackgroundCssClass="modalBackground"

DropShadow="true"

CancelControlID="btnClose"/>

Code behind in vb…

ProtectedSub UploadFile_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)

If FileUpload1.HasFile =TrueAnd IsAdminThen

Dim imageidAsInteger

Dim albumidAsInteger

Dim oAsObject = Request.QueryString("AlbumID")

IfNot oIsNothingThen

albumid =CInt(o)

EndIf

imageid = ImageUtils.uploadImage(imgTitle.Text, albumid, FileUpload1.FileContent)

DataList2.DataBind()

DataList2.SelectedIndex = DataList2.Items.Count - 1

FormView2.DataBind()

FormView2.PageIndex = FormView2.PageCount - 1

ErrorLabel.Text =""

Else

ErrorLabel.Text ="<p>Please select a file to upload<p>"

EndIf

EndSub


yeh it doesnt work. I'm wonder if its to do with the fact that base/master pages are being used, as well as several user controls being placed on an aspx page?
Was anybody ever able to resolve this I have the exact same problem, only controls within a gridveiw fire their events...

I don't think it has anything to do with base pages or master pages. The project I'm working on uses a custom base page, inherits from a master page, and runs more than one user control. The modal popup seems to work just fine. One thing worth considering is building an AJAX Control Toolkit website. You'll find the option if you ran the .vsi installer. It can be informative to look at the reference structure and the web.config after creating a temporary site from that template. Good luck!

Keith


Would you mind posting the markup of your ModalPopup that has working controls?
I finally found the cause of this problem.Smile After going through each control I discovered that when I removed the RequiredFieldValidators from the page, the click events fired. So I put them back and then set causesvalidation = false for the button and again the click event fired. This must be a bug with the extender. So basically you have to disable validation on any control in the modal pupup window.

interesting. ill see if we have this (cant right now) however currently the way it stands, it still does not work. I'm able to do it on a simple aspx page (which does not use a master page) but when using a master page, it does not work.

how do we get it to work with validation, should there be validation in our solution/project?


nope - we dont have any requiredFieldValidators on the pages we are using the ajax control on. - still stuck

Preferred Approach to Existing .Net Server Controls and Client Scripting

In asp.net 1.1, the mechanism I used on many occassions is to add attributes to work some client side script. ie. a .NET dropdownlist:

ddlMonOfficeStart.Attributes.Add("onChange",string.Format("return ValidateTimeSelection('{0}', '{1}', 'divMonOfficeStart', 'divMonOfficeEnd')", ddlMonOfficeStart.ClientID, ddlMonOfficeEnd.ClientID));

First off, I'm not sure if the above approach is necessary with Atlas, but the next question is how to handle this in javascript:

Do I simply get the clientid of the dropdownlist and do my 'normal' javascript - or at this point do I try to 'cast' this dropdownlist object on the client side to the Sys.UI.Select object?

I see this example here:http://atlas.asp.net/docs/util/srcview.aspx?path=~/atlas/samples/controls/simple_control.src - but in this example, these are 'html' elements, not .net server side controls?

In the above attribute, the script might look like this:

<scripttype="text/javascript">

function ValidateTimeSelection(g_ddl1, g_ddl2, g_div1, g_div2) {
var dd1 = ($(g_ddl1));
...
}

</script>

in this line here: var ddl = ($(g_ddl1)) I'd rather like to do something like:

var dd1= new Sys.UI.Select($(g_ddl1));

and utilize the Atlas script library.

Hopefully this makes sense :)

You can simply continue to build your custom control with regaulr JavaScript that is rendered by the control through the Page.ClientScript.RegisterXXXScript methods. Where your 'behavior' is simple, this might still be the best approach.

However, if you wish to build a new control that makes use of the Atlas libraries and perform much more rich behavior in the client, then you can begin to develop custom controls that implement IScriptControl, that can then render the required xml-script (declarative Atlas script) to the client. You'll need of course to ensure that there is a Scriptmanager in the page, in order to render your script. This means that you can divorce yourself from writing complex JavaScript etc.

If you have bew custom behaviors that you want your custom control to make use of, then you could potentially build Atlas client-side behaviors/controls that agfain you can render through the custom control. This would also yield those client-side components for other client-side rich applications.

Monday, March 26, 2012

Prerequisites to run Ajax Enabled Web sites !

Hey,

Do I need to install the Ajax Framework on the server to launch the Ajax Enabled websites.

Thanks and Regards

RS

You don't need to install AJAX extensions on production server, but you have to make sure that file Microsoft.Web.Extensions.dll included in Bin folder of your web application.

HeyJasonMDLi ,

My Questions is not about the Extensions part but about the Frame work. Do I need to Install the Ajax Framework?


No, you don't. Extension I mentioned is exact AJAX Framework you mentioned. Don't forget copy the file into Bin folder of webapp.
No, you don't. Extension I mentioned is exact AJAX Framework you mentioned. Don't forget to copy the file into Bin folder of webapp.

Hey,

Just make sure to check the .net framework version in iis, everything else is done the same way as before. When you compile your solution, all the files will be in the bin folder as mentionned previously.Smile

prevent asp:ImageButton from refreshing image...

Is there a way (with the Dec release) to prevent the image in an image button from refreshing when posting back to the server in an UpdatePanel?

It would seem to defeat the purpose of Ajax to have this image refresh all the time during a post to the server...

Wade.

The idea would be to keep the image button outside the updatepanel so it is not refreshed when the page is posted back.

- Kashif


Actually the behavior is browser dependent. Internet Explorer seems to refresh images by trying to go to reload the image, while Mozilla seems to cache images completely locally and without that funky flash.

In IE if you replace content that contains images references (as UpdatePanel will do) all the images reload. Usually they will come from Cache so it's pretty fast, but there's still some amount of flash. If you use FireFox you don't get that flash. You can hook up Fiddler or other HTTP proxy to see this behavior.

Certainly makes for smoother operation of any sort of callback in FireFox.

+++ Rick --


The best method is to have a script manager control on the page with 'Enable Partial Rendering' set to 'True', and then only put the parts of your page that would be updated on a page refresh within the UpdatePanel controls.

So if you don't want the image to 'blink', it's best to leave it outside of that control.


This is a problem that is currently driving me nuts. I have a large UpdatePanel that has a tab control on it. The tabs are painted using image backgrounds defined in a stylesheet. In IE, using Nikhil's web dev tool, I can see that for every tab all the images are requested and the server responds with code 200. It's like IE's local cache is completely ignored. This is causing an ugly flicker and some repaint issues. I've tried the max-age cache control-cache extension but it doesn't seem to work. I found the best information athttp://aspnetresources.com/blog/cache_control_extensions.aspx.

Does anyboy have any ideas?

This bug is going to kill me too. all the images on the page even those are outside the updatepanel and wrote with <img> tag are flikering too.

Any solution to resolve this problem?


The image flicker has nothing to do with ATLAS - it's an IE bug - IE is refreshing the images when it shouldn't. You can fix that by changing your IE cache settings. I think it happens if you have your cache set to refresh on every page hit. IE apparently considers the partial XmlHttp postback as a page refresh and refreshes all content in the page. Put IE back to auto caching and the flickering should stop.

+++ Rick --


Dear Rick

Thanks For Comment

My IE Caching was set to Auto Already, and here still the killer bug.

Any other Idea?

H.B.F


Hello. This is a bug in IE when it's pulling in background images defined in CSS. As far as I am aware, the solution lies within IIS. Have a read of this: http://erik.eae.net/archives/2007/02/26/13.13.48/

cheers
Anthony

Probelms with Modal Popup via server in code behind

Hi all

I am having problems while adding the modal popup dynamically to my page on the server side on a (web user control). When I set the "TargetControlId" or the "PopupControlId" like this -

ModalPopupExtender modPop = new ModalPopupExtender();
TextBox tbMsg = new TextBox();
tbMsg.ID = "tbMsg";
tbMsg.Text = "Thanks!";
modPop.ID = "modulePopup";
modPop.TargetControlID = hiddenField.ID; //made this hidden field in the user control
modPop.PopupControlID = tbMsg.ClientID;
modPop.BackgroundCssClass = "modalBackground";
modPop.X = 200;
modPop.Y = 200;

Now what is happening is that the ID's that go to the modal popup javascript (ScriptResource etc) I see that it goes in as the name of the textbox itself "tbmsg" instead of the client ID ? so I see something like document.getElementByID("tbMsg") !!!

What am I supposed to do??

Thanks in advance

Sanchita

hiddenField.ClientID will get the ID which is generated by ASP.net

Saturday, March 24, 2012

Problem adding toolkit to the web.config on my server

I am trying to add the toolkit to my server's web.config so that I do not have to register the toolkit on each page that I use the extenders on. I have added the following config items but am receiving the error listed below when I attempt to use a control. Is there an issue with using the extenders on master pages? Everything works fine from a VWD perspective, intellisense picks up the toolkit controls just fine. The error only occurs on the server. Any help would be greatly apprectiately.

I have added the following to the <compilation><assemblies> section:

<add assembly="AjaxControlToolkit, Version=1.0.10618.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"/>

I have also added the following within the <system.web> section:

<pages>
<controls>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit" />
</controls>
</pages>

Error text:


Parser Error

Description:An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message:Unknown server tag 'ajaxToolkit:TextBoxWatermarkExtender'.

Source Error:

Line 48: ErrorMessage="User Name is required." Display="dynamic" ToolTip="User Name is required." ValidationGroup="ctl00$ctl00$Login1">*</asp:RequiredFieldValidator>Line 49:Line 50: <ajaxToolkit:TextBoxWatermarkExtender id="wm1" runat="server" TargetControlID="UserName" WatermarkText="Username" />Line 51: </td>Line 52: </tr>

The problem turned out to be an issue with the AJAX Extension configuration in the web.config. To fix it I just copied the info from the web.config from the Extensions install directory.


I am trying to do this right now too. Could you provide a little more detail about your fix? Where is the Extensions install directory? And what info did you copy from the web.config?

Also, how do I determine what the proper assembly info to use (i.e. version# and public key token...)

Thanks!


The path for the Extensions install directory on my dev machine is:

C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025

That should be the default path for the AJAX Extensions installer.

Located in that folder should be a web.config file. All of the info in there needs to be copied into the web.config for your app. You'll have to make sure you aren't duplicating sections if you just paste the whole bit in your config. Posted below is a direct copy of the web.config for your convenience.

As for the issue of knowing which version and public token, I just take those from the samples. In the case of the Extensions, the config below lists the correct info and you shouldn't have to change it. For the case of the toolkit, the version will be the same as the release you are currently using. As for the public token, I'm not entirely sure about that as I have not updated my toolkit to the newest release. If you figure that out post back here to have it documented. (I'll do the same when I upgrade)

I hope this helps solve your issue.

<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> <system.web> <pages> <controls> <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </controls> </pages><!-- 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="false"> <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> </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>

Problem attaching Wiki Database

I'm running SQL Server 2005 Developer edition. I've attempted to attach the MDF file as a database but I get an error that the LDF file doesn't exist. How can I get the Wiki working with SQL Server 2005 Developer Edition?
Regards,
John GriebI have the same problem with attachdatabase too,where is the ldf file?
who had the same problem,tell me a answer please

John Grieb wrote:

I'm running SQL Server 2005 Developer edition. I've attempted to attach the MDF file as a database but I get an error that the LDF file doesn't exist. How can I get the Wiki working with SQL Server 2005 Developer Edition?


I too had the same problems, when you are attaching the mdf file there are a couple things that you need to do:
1. Click "Add" and browse to the MDF file in need
2. In the "Databases to Attach Box", you'll want to modify the "Attach As" field from "D:\WEBSITES\ATLAS\MAIN\APPS\ATLASWIKI\APP_DATA\ATLASWIKI.MDF" to "atlaswiki" (note that you don't add the .mdf extention, you can also change it to whatever you want, incase you have multiple instances running, ie "atlaswiki2")
3. In the Box below "Databases to attach:", there should be two records, one for the mdf and one for the ldf, and the ldf should say "not found" under the "message" column. Highlight the ldf record and click the remove button.
You should be able click ok and attach now, and SQL Server will create the ldf for you. I tried creating a blank ldf file in an appropriate location, but that bombs too, this way is simpler anyway.
Repeat this process for the aspnetdb.mdf, as you'll need this for your user login/authentication stuff.
You'll also have to modify your web.config and change:

<addname="defaultSqlServer"connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|AtlasWiki.mdf" />
<addname="LocalSqlServer"connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />

to:

<addname="defaultSqlServer"connectionString="Data Source=(local);Initial Catalog=atlaswiki;Integrated Security=True" />
<addname="LocalSqlServer"connectionString="Data Source=(local);Initial Catalog=aspnetdb;Integrated Security=True" />
I hope this works for you, good luck! Please post back if it doesn't work.
-von


Worked like a charm.
Who da man....You da man!!!!!!
Thanx,
John Grieb

I have tried the above method, but I run into the following error.

Could not open new database 'atlaswiki'. CREATE DATABASE is aborted.
File activation failure. The physical file name "D:\WebSites\Atlas\main\apps\AtlasWiki\App_Data\atlaswiki_log.ldf" may be incorrect.
The log cannot be rebuilt when the primary file is read-only. (.Net SqlClient Data Provider)

The problem seems to be that the mdf file is showing up as read-only, but when i view the properties on it, it does not show up as read-only, only the file folder holding it does. When i try to change that folder, it seems to work, but next time i go to view it is back to read only. I have tried closing all of the applications and rebooting the machine. Thanks for your help.

-Dan


Had the same problem. This worked:

For some reason a connection cannot be made using the default connection strings on my computer (it's an installation problem specific to this computer, the installation worked right away on another -virtual- computer).

I changed the connection strings (there are 2) to something like"Data Source=localhost;Persist Security Info=True;User ID=sa;Password=******;AttachDBFilename=c:\WikiAtlasWebSite1\app_data\aspnetdb.mdf" and the same for atlaswiki.mdf.

If the wiki works, read the article on enabling searching to find out that one can actualy attach databases without logfiles, you just cannot do it with the SQL Server Management Studio attach wizard.


Can you tell me what you would use to attach without the SQL Server Management Studio or link to the other post? I can't find it.

Thanks.


What I meant was that attaching using the wizard (right click databases en select 'Attach') in SQL Server Management Studio won't work if the logfile is missing. It can however be done by running the query ( in the Management Studio):

sp_attach_single_file_db N'atlaswiki', N'C:\WikiAtlasWebSite1\App_Data\atlaswiki.mdf' (or where the file is located on your computer)

The article I referred to is an article in the Wiki itself which cannot be viewed unless the Wiki is running (a catch 22 situation).


I get this error now. I try setting the properties of the file to be not read only, and they don't show up that way, but the folder containing it shows up as read only even after i check it off and set it to propagate to subfolders.

File activation failure. The physical file name "D:\WebSites\Atlas\main\apps\AtlasWiki\App_Data\atlaswiki_log.ldf" may be incorrect.

The log cannot be rebuilt when the primary file is read-only.

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'atlaswiki'. CREATE DATABASE is aborted.


Folders always show up as read-only in XP, 2000 or 2003. It doesn't mean anything.

Make sure that the service account that is doing the actual work (ASPNET) has sufficient rights.


I am getting the following error now.

Msg 1813, Level 16, State 2, Line 1

Could not open new database 'atlaswiki'. CREATE DATABASE is aborted.

Msg 602, Level 21, State 50, Line 1

Could not find row in sysindexes for database ID 18, object ID 1, index ID 1. Run DBCC CHECKTABLE on sysindexes.

Any ideas?

Problem during Uploading the file

Hi

The Problem that am facing is

1)The path of the file that is saving in the database is "Path of the Server" + "images/"Up" of the path variable. I dont know why.

2) When i click on the Save Button, the code says File Uploaded but the file is missing from the location. Actually i think that "SaveAs" function is not working properly.

Boolean fileOK = false;
String path = Server.MapPath("/images/Uploads/employee/images/");
if (!(Directory.Exists(path)))
{
Directory.CreateDirectory(path);
}
lblInformation.Visible = true;
if (fuplEmployeeImage.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(fuplEmployeeImage.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".png", ".jpeg", ".jpg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
}
}

if (fileOK)
{
if (File.Exists(path + fuplEmployeeImage.FileName))
{
lblInformation.Text = fuplEmployeeImage.FileName + " already Exists.Please Rename the file and try again.";
}
else
{
try
{
fuplEmployeeImage.PostedFile.SaveAs(path + fuplEmployeeImage.FileName);
_prEmployee.Attachment = path + fuplEmployeeImage.FileName;
lblInformation.Text = fuplEmployeeImage.FileName + " File Uploaded!";
}
catch (Exception ex)
{
lblInformation.Text = fuplEmployeeImage.FileName + " File could not be Uploaded.";
}
}
}
else
{
lblInformation.Text = "Cannot accept files of this type.";
}
}

Any help is greatly appreciated.

Thanx

If you're using AJAX with the FileUpload control, it's never going to work. See this thread for more details:

http://forums.asp.net/t/1107788.aspx


Hi

Thanx for your response.

I know this thing that File Upload Control doesn't work inside Update Panel of AJAX.For that purpose i had fire PostBacktrigger for thec control which actually calls FileUpload Control.

So that is not an issue

Bye


Hi,deepakleo2003

I'd like to give you a demo:

<%@. Page Language="C#" %>
<%@. Import Namespace="System.IO" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
Boolean fileOK = false;
String path = Server.MapPath("images/");
if (!(Directory.Exists(path)))
{
Directory.CreateDirectory(path);
}
lblInformation.Visible = true;
if (fuplEmployeeImage.HasFile)
{
String fileExtension = System.IO.Path.GetExtension(fuplEmployeeImage.FileName).ToLower();
String[] allowedExtensions = { ".gif", ".jpg", ".png", ".jpeg" };
for (int i = 0; i < allowedExtensions.Length; i++)
{
if (fileExtension == allowedExtensions[i])
{
fileOK = true;
break;
}
}

if (fileOK)
{
if (File.Exists(path + fuplEmployeeImage.FileName))
{
lblInformation.Text = fuplEmployeeImage.FileName + " already Exists.Please Rename the file and try again.";
}
else
{
try
{
fuplEmployeeImage.PostedFile.SaveAs(path + fuplEmployeeImage.FileName);
//_prEmployee.Attachment = path + fuplEmployeeImage.FileName;
lblInformation.Text = fuplEmployeeImage.FileName + " File Uploaded!";
}
catch
{
lblInformation.Text = fuplEmployeeImage.FileName + " File could not be Uploaded.";
}
}
}
else
{
lblInformation.Text = "Cannot accept files of this type.";
}
}
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblInformation" Visible="false" runat="server" Text="lblInformation"></asp:Label>
<asp:FileUpload ID="fuplEmployeeImage" runat="server" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>

If this help you,don't forget mark it as a answer.Thanks!

Let me know if you need more info.

Wednesday, March 21, 2012

Problem in Deploying ASP.NET AJAX 1.0

I had deployed my application on server but getting error in :

"<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="System.Web.UI.Compatibility.CompareValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>"

Getting error in this line in web.config ...Please help me to solve this.

This is an exact error...

Configuration Error

Description:An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message:Could not load type 'System.Web.UI.Compatibility.CompareValidator' from assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35'.

Source Error:

Line 27: </controls>Line 28: <tagMapping>Line 29: <add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="System.Web.UI.Compatibility.CompareValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>Line 30: <add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="System.Web.UI.Compatibility.CustomValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>Line 31: <add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="System.Web.UI.Compatibility.RangeValidator, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>



Looks like an old web.config. See http://smarx.com/posts/what-happened-to-the-validators-in-asp-net-ajax-1-0-rtm.aspx.

I have add Validators.dll and made the chages .

Still the problem is ...

Parser Error

Description:An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message:Could not load type 'System.Web.UI.Compatibility.RequiredFieldValidator' from assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error:

Line 1: <%@. page language="C#" autoeventwireup="true" inherits="Login_Default, App_Web_6jo3nll1" %>Line 2: Line 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">



Are you sure you updated your web.config as instructed on Matt's blog? You should be hitting System.Web.UI.WebControls.RequiredFieldValidator, not System.Web.UI.Compatibility.RequiredFieldValidator as shown in the error above.

Problem in file uploading with Ajax

I want to upload an image on server. My source below is working well. But when I keep the same things in Update Panel it didn't work. Can some one help me on this strange behavior please?

Thanks!

ImageUpload.aspx.cs
 
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
 
namespace Articles
{
   publicclass Default : Page
   {
       public HtmlInputFile   Picture;
       public Label           Message;
       public Image           UploadedPic;
 
       publicvoid UploadImage(object sender, EventArgs e)
       {
           if (Picture.PostedFile !=null)
           {
               string PicType = Picture.PostedFile.ContentType.ToString();
               if (PicType == "image/jpeg" || PicType == "image/gif" || PicType == "image/pjpeg"
                   || PicType == "image/bmp")
               {
                   try
                   {
                       string PicName = Picture.PostedFile.FileName;
                       string NewPicName = (string)Session.SessionID + "_" + PicName.Substring(PicName.LastIndexOf(@dotnet.itags.org."\")+1);
                       string UploadPath = Request.PhysicalApplicationPath + @dotnet.itags.org."\Upload\";
 
                       Picture.PostedFile.SaveAs(UploadPath + NewPicName);
 
                       Message.Text = "Picture successfully uploaded to server!";
                       UploadedPic.AlternateText = "Uploaded picture...";
                       UploadedPic.ImageUrl = UploadPath + NewPicName;
                       UploadedPic.Visible =true;
                   }
                   catch (Exception exc)
                   {
                       Message.Text = exc.ToString();
                   }
               }
               else
                   Message.Text = "File format not supported!";
           }
       }
   }
}

ImageUpload.aspx
 
<%@dotnet.itags.org. Page Language="C#" Codebehind="ImageUpload1.aspx.cs" Inherits="Articles.Default" %>
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>Image Upload #1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
 
<h3>Image Upload #1</h3>
<form enctype="multipart/form-data" runat="server">
   <table>
       <tr>
           <td>Image:</td>
           <td><input id="Picture" type="file" runat="server"/></td>
       </tr>
   </table>
   <br/>
   <input type="submit" value="Upload >>>" onserverclick="UploadImage" runat="server"/>
</form>
 
<asp:label id="Message" runat="server"/>
 
<hr>
 
<asp:image id="UploadedPic" visible="False" runat="server"/>
 
</body>
</html>

Hi,

unfortunately the FileUpload control, like some other controls, don't work together with the UpdatePanel. So no go.

You can check the controls out that don't work with it here:

Taken from the documentation:http://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx

Controls that Are Not Compatible with UpdatePanel Controls

The following ASP.NET controls are not compatible with partial-page updates, and are therefore not supported inside anUpdatePanel control:

TreeView andMenu controls.

problem in returning DataTable

Hello Guys,

i am calling a ajax call to page method which returns DataTable. but i got following error

"The server method 'GetInfo" failed with the following error: System.InvalidOperationException-- A circular reference was detected while serializing an object of type 'System.Reflection.Module' "

does ajax support serializing datatable?

Thanks,

Kiran

Hi,kalvagadda

The Latest version of Ajax Does not have the support of DataTable and DataSet.

You can check these links for answer and more info:

http://forums.asp.net/t/1121145.aspx

http://forums.asp.net/t/1119899.aspx

http://forums.asp.net/t/1122022.aspx

http://dotnetslackers.com/articles/ajax/ASPNETAjaxGridAndPager.aspx

Let me know if you need more info.

Hope this helps.

Thanks!


Hi,

Thanks for the reply. Links were helpful.

Thanks,

Kiran


ThanksJin-Yu Yin - MSFTfor providing more info

Problem in Transporting from july ctp to beta 2

Hi!

I've been having a problem that i still can't resolve.

In July CTP i had this page that server.transfer to another page that had a bunch of custom made tab's. These tab's run by JavaScript and execute on each run a click in an hidden button, the hidden button made a request to fill the user control of that tab, during that request the UpdateProgress is runing.

Ok this worked in the July CTP release, but now in Beta 2 release it isn't working. It keeps giving an alert saying that server error 404 and server error 12030. Since error 404 is Page not Found exception i think it has to do with the non changing of the address bar address...

I've read some post's to try to see if i get some answer and everyone just keeps saying to use response.redirect. I don't want to use response.redirect, it makes 2 postbacks and i would have to throw the data that i need to transfer to that page by querystring and that is something that i can't have.

Can anyone give me some lights?

Thanks,

Sérgio

I forgot where I found this, but I found out that if you have any web methods you need to add:

[Microsoft.Web.Script.Services.

ScriptService()]

to the service.

Example:

///

<summary>

///

Summary description for wsSelectGroup_Data

///

</summary>

[

WebService(Namespace ="http://tempuri.org/")]

[

WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

[Microsoft.Web.Script.Services.

ScriptService()]

public

classwsSelectGroup_Data : System.Web.Services.WebService

{


No WebMethods.

It's just a simple plain server side execute in a page that was reached through server.transfer

I just can't get why it isn't working anymore...


hello.

well, it looks like a specific case which is not widely used, can you build a demo site that reproduces the problem?


Hi,

I saw this thread and although my problem is not quite the same, I am too having difficulties when usingserver.transfer to load a page using an UpdatePanel, somehow navigating to an Ajax enabled page using server.transfer get the UpdatePanel mixed up with the path!

here is some demo code to illustrate my problem:

2 folders "folder1" and "folder2" containing respectivelly "callingPage.aspx" and "ajaxPage.aspx"

Problem in uploading ajax toolkit on web server

Respected Sir,

I have used Dropshow simple control in ajax control tool kit,

it's all run on localhost, but it's gave problem on web server which i deployed hall application

The error is as shown below:

It shows thatCould not found Micosoft.Extension.Design.Dll

I can solve that error by copying that dll file on my bin folder in server,

But how can i permanently removed that error ,

can you explain me ?

What ajax version i have to download for that ? pls give me proper guidance.

i m waiting for you response.

Happy Coding !

You can reference the Micosoft.Extension.Design.Dll into your project or add the Micosoft.Extension.Design.Dll into the GAC usint GACUTIL.EXE will install the dll into the gac.Hope this helps

Problem installing the documentation

When I build the website for the documentation I get the following errors:

Error 37 Unknown server tag 'Samples:ClientVerification'. C:\AJAX Documentation\Samples\LocalizingClientResourcesWalkthrough\cs\Default.aspx 40


Error 36 Could not load file or assembly 'LocalizingScriptResources' or one of its dependencies. The system cannot find the file specified. C:\AJAX Documentation\Samples\LocalizingClientResourcesWalkthrough\cs\Default.aspx 2

I followed the instructions in the readme.txt file and the files are unzipped into the C:\AJAX Documentation folder.

bump

problem of find control in nested Formview control

I can find my Textbox contols in following structures,

<asp:PanelID="Popup1"runat="server"CssClass="popup"style="display:none;">

<asp:UpdateProgressid="UpdateMessagesProgress"DynamicLayout="false"runat="server"DisplayAfter="0">

<ProgressTemplate>

Processing...

</ProgressTemplate>

</asp:UpdateProgress>

<asp:UpdatePanelID="UpdatePopup"runat="server"UpdateMode=Always>

<ContentTemplate>

<asp:FormViewid="FormView1"runat="server" DefaultMode="Edit">

<EditItemTemplate>

<asp:TextBoxid="title_TextBox"runat="server" Text='<%# Bind("title") %>'></asp:TextBox>

............

</EditItemTemplate>

</asp:FormView>

</ContentTemplate>

</asp:UpdatePanel>

</asp:Panel>

I want to set the textbox's visible to false but can't find it. Please help me!!

Check out

http://forums.asp.net/t/1107107.aspx it may help you


Try this one :

FormView1.FindControl('title_TextBox').Visible = false


I still can't solve this problem. Any other ideas?


Finally, I can find my Textbox control by using following method:

In RowUpdating envent:

protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow MyRow = GridView2.Rows[e.RowIndex];

if (MyRow != null)
{
TextBox exit_price_text = MyRow .FindControl("exit_price_TextBox") as TextBox;
.....

}

}