2 שאלות על validating user input

erezzi

New member
אולי מישהו כבר ראה את זה...

אני בונה דף ASP פשוט. אם אני מכניס textbox אחד אין בעיות. אם אני מוסיף עוד אחד או שניים ומריץ, השני ו/או השלישי מופיעים בצבע צהוב! למה?
 

erezzi

New member
2 שאלות על validating user input

למדתי עכשיו על ה-controls שמשמשים לבדיקת הקלט של המשתשמש ויש לי 2 שאלות: 1. מתי נבדק הקלט? האם כאשר ה-control הנבדק איבד פוקוס? גיליתי שאם אני מוסיף סתם כפתור לטופס ולוחץ עליו, מייד נבדקים כל ה-controls. 2. נניח שבסוף הטופס יש לי כפתור submit שאמור להעביר אותי לטופס הבא. אני רוצה לעבור לטופס הבא רק אם הטופס הנוכחי תקין. איך אפשר לקבל חיווי בעניין הזה ולהחליט האם לאפשר מעבר לטופס הבא או למשל לעשות disable ולכפתור submit? תודה מראש ארז
 

gilad g

New member
תשובות ../images/Emo13.gif

1. הקלט נבדק לאחר לחיצה על כתפור שיש לו מאפיין CausesValidation ששווה ל-True. 2. המאפיין שאתה מחפש הוא Page.IsValid
 

erezzi

New member
באותו עניין

כל ה-controls שמטפלים ב-validation לא מטפלים במצב של string ריק. לדוגמא: אם המשתמש צריך להכניס key מסויים, לא תינתן התראה אם הוא הכניס string ריק. ניתן להגדיר control של required field לצורך כך. הבעיה היא איך להציג את ההתראות של 2 ה-controls שמטפלים באותו שדה. הרי אי אפשר לשים את 2 ה-controls המטפלים אחד על השני בטופס. יש דרך מקובלת וסטנדרטית לטפל בבעיה הזאת? תודה מראש ארז
 

gilad g

New member
אני לא מבין את הבעיה...

אתה פשוט שם שני Validation Controls בטופס שלך..
אם מפריע לך שהם נמצאים אחד ליד השני, ותופסים סתם מקום, אתה יכול להשתמש ב-ValidationSummary, שמציג את הודעות השגיאה, אחת מתחת לשניה, בצורה יפה
 

erezzi

New member
שגיאה ב-SourceExists

כאשר אני קורא לפונקציה הבאה:
EventLog.SourceExists(logName)​
מתקבלת השגיאה הבאה: Run-time exception thrown : System.Security.SecurityException - Requested registry access is not allowed. ב-help של הפונקציה ב-MSDN אין שום אזהרות בעניין הזה. כמו כן, אני אדמיניסטרטור על המחשב. מה הבעיה? תודה מראש ארז
 

gilad g

New member
מתוך אותו MSDN:

If you are using event logs in an ASP.NET application, access to the event logs is through another account, the ASPNET account. The default settings of the ASPNET user account restrict access to the event logs. The ASPNET user account does not have permission to create new categories, though it can add entries to an existing log. You can use impersonation with the ASPNET account to allow creation of new categories. The impersonation identity must have sufficient privileges to create categories. If your application needs event logs that can be specified before deployment, they can be created by the deployment project. For more information, see ASP.NET Web Application Security.
 

yuval k

New member
../images/Emo45.gif

סביר ביותר (ואף נכון) שלאפליקציות ASP.net יש הרשאות מעטות לגישה למערכת. ומעבר לזה, ידוע שאפילקציות ASP.net רצות כמשתמש מיוחד
 

erezzi

New member
impersonation

מה הכוונה ב: You can use impersonation with the ASPNET account to allow creation of new categories. איך עושים את זה? בנוסף, אני מבין שלא כדאי לתת לחשבון ASPNET הרשאות של administrator.
 

gilad g

New member
impersonation הוא

"התחזות" של ASP.NET לחשבון אחר, כך ש-ASP.NET ירוץ תחת חשבון אחר עם פחות הגבלות, ועם הרשאה לשנות את ה-Event Log.
 

erezzi

New member
לא הצלחתי לעשות את זה

אני מבין. איך עושים את זה בפועל? ניסיתי להוסיף לקובץ Web.config את השורה הבאה:
<identity impersonate="true" name="erezzi" password="" />​
בהרצה חטפתי שגיאה (ה-attribute שנקרא name לא מוכר). אשמח לקבל עזרה. תודה ארז
 

erezzi

New member
כמעט עובד

שיניתי אבל קיבלתי את השגיאה הבאה: Parser Error Message: Could not create Windows user token from the credentials specified in the config file. Error from the operating system 'Logon failure: user account restriction. Possible reasons are blank passwords not allowed, logon hour restrictions, or a policy restriction has been enforced. ' שם המשתמש הוא erezzi. האם צריך לתת לו אולי גם domain (אני לא חושב שיש לי כזה מכיוון שאני לא נמצא ברשת). בנוסף, אין לחשבון הזה ססמא וכנראה שזה מרגיז אותו...
 
למעלה