Hi
In below code i have used Pattern . I want to declare this line at one location. Whenever it is changed effect takes place on all Aspx pages. It should appear in SweetAlert.
pattern="[a-zA-Z\s\.]*" title="Valid characters: Alphabets/Space & . (Dot)" .
*
Thanks
Ramco RamcoPosted Sep 10, 2024, 7:45 AM
Hi Naimish
Can we write the code other than Web.Config file.
Thanks
Naimish MakwanaPosted Sep 9, 2024, 7:01 AM
To centralize the pattern and title attributes for your textboxes, you can define them in a single location and reference them in your ASPX pages. Here’s how you can do it:
Step 1: Define the Pattern and Title in Web.config
Add the pattern and title as app settings in your
Web.configfile.Step 2: Create a Helper Method in Code-Behind
Create a helper method in your base page or a utility class to retrieve these settings.
Step 3: Use the Helper Method in Your ASPX Pages
Use the helper method to set the pattern and title attributes in your ASPX pages.
Step 4: Implement SweetAlert for Validation Messages
To display validation messages using SweetAlert, you can use JavaScript to check the validity of the textboxes and show the alert.
This setup ensures that any changes to the pattern or title are reflected across all your ASPX pages, and SweetAlert is used to display validation messages.
Thanks
Tahir AnsariPosted Sep 8, 2024, 1:46 PM
Alternatively, if you want to handle this purely on the client-side without creating a server-side control, you can use JavaScript to apply the attributes dynamically
Add JavaScript to Set Attributes:
Update ASPX Page
Tahir AnsariPosted Sep 8, 2024, 1:45 PM
Custom Control Approach
Create a User Control:
CustomTextBox.ascxCode Behind for User Control
in the code-behind file,
CustomTextBox.ascx.csUse the User Control in ASPX Pages: