Wednesday, October 26, 2005

Login Control :: Password Recovery :: How-To send emails

that the emails issues are working fine, you will need to adapt the web.config with the following element:

≶blockquote>≶strong>≶system.net>
≶mailsettings>
≶smtp deliverymethod="Network">
≶network host="smtp.xyz.com" from="roni.schuetz@hotmail.com">
≶/smtp>
≶/mailsettings>
≶/SYSTEM.NET>≶/strong>≶/blockquote>

Asp.Net 2.0 Themes und URL-Rewriting

this is a well know problem with the relativ path's. Themes are using by default relativ Paths. the workaround is to use the follwoing method:

the reg-ex which is used here: ""

Notice: its just match css-links like in the sample!!!!

public override void Write(byte[] buffer, int offset, int count){string strBuffer = System.Text.UTF8Encoding.UTF8.GetString(buffer, offset, count);
// ---------------------------------// Wait for the closing tag// ---------------------------------Regex eof = new Regex("", RegexOptions.IgnoreCase);
if (!eof.IsMatch(strBuffer)){responseHtml.Append(strBuffer);}else{responseHtml.Append(strBuffer);
string finalHtml = responseHtml.ToString();Regex re = null;
// Css-Files auf die absolute Client-URL mappenre = new Regex("", RegexOptions.IgnoreCase);finalHtml = re.Replace (finalHtml, new MatchEvaluator (CssMatch));
// Write the formatted HTML backbyte[] data = System.Text.UTF8Encoding.UTF8.GetBytes(finalHtml);
responseStream.Write(data, 0, data.Length);}
}
private string CssMatch(Match m){return m.ToString().Replace(m.Groups[1].Value, ConfigurationManager.AppSettings["ApplicationRoot"] + m.Groups[1].Value);}

Source: http://blogs.dotnetgerman.com/thomas/PermaLink,guid,f211331c-b175-4a25-8958-ece6bc6d364a.aspx

Workaround for ASP.NET 2.0 bug: LoadControl gives an exception in a TemplateControl

[since june CTP 2005 this bug is not available anymore]

http://blogs.infosupport.com/raimondb/archive/2005/04/29/203.aspx?Pending=true

ASP.NET - Relative Url's

ASPX:


HTML Client output:

somewhere else, not inside the control you can use the ResolveUrl("~/bilder/spacer.gif");

Masterpages per Browser

yes its possible to generate for each differnent browser its own MasterPage.

<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Default.aspx.cs"
Inherits="_Default"
ie:MasterPageFile="~/MasterPage_IE.master"
mozilla:MasterPageFile="~/MasterPage_Firefox.master"
%>

ASP.NET 2.0 URLMappings

do we need a special url? as short as possible?

so make from:

http://www.xyz.ch/testApp/testApp1/Version51/thisIsASamplePageWhatEverItIs.aspx

http://www.xyz.ch/myPage.aspx


mappedUrl="~/testApp1/Version51/thisIsASamplePageWhatEverItIs.aspx"/>

MasterPage, How-To change it on the fly

surely you can also change your masterPage on the fly. the only thing which has to be done is the following thing:

NOTICE: think about the page cicle!!!!

protected override void OnPreInit(EventArgs e){object tpl = Request.QueryString["Template"];if (tpl == null tpl.ToString() == "Default"){this.MasterPageFile = "~/Templates/Category/Standard.master";}else{this.MasterPageFile = "~/Templates/Category/Sample.master";}}

JavaScript Debugging

Clear the "disable script debugging" checkbox in Internet Explorer's advanced properties. Add the keyword "debugger" somewhere within your JavaScript.When you run the web page from Visual Studio in debugging mode, viola--when it hits the "debugger" statement, the Visual Studio debugger window takes control, you can set your break points, and proceed as normal. You can even get very clever setting the "debugger" from within script created from you server-side code that's registered with one of the many "Register" client-side script block methods.

Tuesday, October 25, 2005

How-To handle RoleManagment features with my own Database

The role-based features in .net 2.0 are using some place to maintain the data. By default this will be the "SQL Server Express" instance which is automatically installed with the Visual Studio. If you dont make this wizard every try will end in the express version :-( - get sad from it but after several researches I have found the solution.

If you would like to use your own DB then go through the follwoing steps:

1 - Create DB
2 - Start -> Programs -> Microsoft Visual Studio 2005 ->
Visual Studio Tools -> Visual Studio 2005 Command
Prompt
3 - write "aspnet_regsql"
4 - Go through the Wizard
5 - Open your Web.Config file and add the following elements:



6 - Run now from your Visual Studio the WebSite / ASP.Net
Configuration [ WebAdmin Tool ]
7 - At the Security you should now choose the Authentication
type, adding your roles and user

thats the whole trick behind it.

Thursday, October 13, 2005

Javascript Control Helpers funcitons

Howto call:
setGroup(!this.checked, 'name1,name2,name3,etc')

radioPropertyChanged(this, 'name1,name2,etc')

getControls();

callOnclick('name');

//////////////////////////////////////
/**
* JavaScript functions for enabling / disabling controls
*/

function radioPropertyChanged(control, controlnamestring) {
if (event.propertyName == '' event.propertyName == 'checked') {
setGroup(control.checked, controlnamestring);
}
}

function setGroup(enabled, controlnamestring) {
// alert(controlnamestring + ': ' + enabled);
var controlnames = controlnamestring.split(',');
for (var i=0; i var control = document.getElementById(controlnames[i]);
if (control) {
if (!enabled && 'isvalid' in control)
ValidatorEnable(control, enabled)
else {
control.enabled = enabled;
control.disabled = !enabled;
}
if (!enabled) {
try {
var tagName=control.tagName.toLowerCase();
if(tagName=='input') {
//alert('Found checked in ' + control.id);
var type=control.type.toLowerCase();
if (type=='text') {
control.value='';
if (control.onchange) control.onchange();
}
else if (type=='radio' type=='checkbox'){
control.checked = false;
if (control.onclick) control.onclick();
if (control.onpropertychange) control.onpropertychange();
}
}
else if (tagName=='select') {
// alert('Found selectedIndex in ' + control.id);
control.selectedIndex = -1;
// control.onchange();
}
}
catch(ex){
//ignore
}
}
}
// else alert('control ' + controlname[i] + ' not found!');
}
}

function getControls(){
var ControlsArr = new Array();
ControlsArr = document.forms[0].getElementsByTagName('input');
for(var i=0; i {
if(ControlsArr[i].type == 'checkbox' ControlsArr[i].type == 'radio'){
//alert(ControlsArr[i].id);
callOnclick(ControlsArr[i].id);
}
}
}

function callOnclick(controlName) {
var control = document.all(controlName);
if (control && control.onclick) control.onclick();
else if (control && control.onchange) control.onchange();
else if (control && control.onpropertychange) control.onpropertychange();
}

Thursday, October 06, 2005

javascript "loop through all the options and test each one until"

You have to loop through all the options and test each one until you find
it, this example assumes you're testing against text value:

function setListbox(name, value, caseSensitive)
{
var oList = document.forms['abc'].elements[name];
var sTestValue = (caseSensitive ? value : value.toLowerCase());
var sListValue;
for (var i = 0; i < oList.options.length; i++)
{
sListValue = (caseSensitive ? oList.options[i].text :
oList.options[i].text.toLowerCase()); //change text to value if you wish to
compare by value of listbox.
if (sListValue == sTestValue)
{
oList.selectedIndex = i;
break;
}
}



}


setListbox("Country", "Canada", true);

untested code provided by joe, dont know how that is, but anyway thanks

Shared Cache - .Net Caching made easy

All information about Shared Cache is available here: http://www.sharedcache.com/. Its free and easy to use, we provide all sources at codeplex.

Facebook Badge